Submission #35121344


Source Code Expand

#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
// #define MOD (998244353)
#define INF (1e9+7)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
#define int ll
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
using P=pair<ll,ll>;
template<class T>using priority_queue_asd=priority_queue<T, vector<T>, greater<T>>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pl(T x){cout << x << " ";}
template<class T>void pr(T x){cout << x << endl;}
template <class T, class... Ts> inline void pr(T Tar, Ts... ts) { std::cout << Tar << " "; pr(ts...); return; }
template<class T>void prvec(vector<T>& a, int k=-1){if(k==-1){k=a.size();} k=min(k, (int)a.size()); if(k>0){rep(i, k-1){pl(a[i]);} pr(a[k-1]);}else{pr("");}}
template<class T>void prarr(arr<T>& a){rep(i, (int)a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}

signed main()
{
    int n, k; cin >> n >> k;
    vint(a, k);

    vll dp(n+1, 0);

    for(int i=1; i<=n; i++){
        rep(j, k){
            if(a[j] > i) break;
            chmax(dp[i], i - dp[i-a[j]]);
        }
    }

    pr(dp[n]);
    return 0;}

Submission Info

Submission Time
Task D - Stones
User rym903
Language C++ (GCC 9.2.1)
Score 400
Code Size 2234 Byte
Status AC
Exec Time 8 ms
Memory 3720 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 8 ms 3504 KiB
hand_02.txt AC 2 ms 3636 KiB
hand_03.txt AC 2 ms 3580 KiB
random_01.txt AC 7 ms 3720 KiB
random_02.txt AC 4 ms 3656 KiB
random_03.txt AC 2 ms 3720 KiB
random_04.txt AC 2 ms 3504 KiB
random_05.txt AC 5 ms 3688 KiB
random_06.txt AC 5 ms 3552 KiB
random_07.txt AC 4 ms 3524 KiB
random_08.txt AC 4 ms 3688 KiB
random_09.txt AC 5 ms 3496 KiB
random_10.txt AC 3 ms 3528 KiB
random_11.txt AC 4 ms 3684 KiB
random_12.txt AC 2 ms 3616 KiB
random_13.txt AC 5 ms 3576 KiB
random_14.txt AC 2 ms 3444 KiB
random_15.txt AC 5 ms 3500 KiB
random_16.txt AC 3 ms 3544 KiB
random_17.txt AC 5 ms 3684 KiB
random_18.txt AC 2 ms 3476 KiB
random_19.txt AC 2 ms 3632 KiB
random_20.txt AC 2 ms 3564 KiB
random_21.txt AC 3 ms 3688 KiB
random_22.txt AC 5 ms 3540 KiB
random_23.txt AC 5 ms 3580 KiB
random_24.txt AC 3 ms 3664 KiB
sample_01.txt AC 2 ms 3500 KiB
sample_02.txt AC 3 ms 3604 KiB
sample_03.txt AC 3 ms 3500 KiB