답안 #236704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236704 2020-06-03T04:27:23 Z LittleFlowers__ Candies (JOI18_candies) C++17
8 / 100
39 ms 63616 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int N=2010;

int n;
int a[N];
int f[N][N],g[N][N];

main(){
    #define task "3"
    //freopen(task".inp","r",stdin);

    n=in;
    forinc(i,1,n) a[i]=in;

    reset(f,-127), reset(g,-127);

    forinc(i,0,n) g[i][0]=0;


    forinc(i,1,n){
        forinc(j,1,(n+1)/2){
            g[i][j]=max(g[i-1][j],f[i-1][j]);
            f[i][j]=g[i-1][j-1]+a[i];
        }
    }
    forinc(i,1,(n+1)/2)
        cout<<max(f[n][i],g[n][i])<<"\n";
}

Compilation message

candies.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 63616 KB Output is correct
2 Correct 38 ms 63608 KB Output is correct
3 Correct 38 ms 63616 KB Output is correct
4 Correct 38 ms 63616 KB Output is correct
5 Correct 38 ms 63608 KB Output is correct
6 Correct 39 ms 63616 KB Output is correct
7 Correct 38 ms 63616 KB Output is correct
8 Correct 38 ms 63608 KB Output is correct
9 Correct 38 ms 63616 KB Output is correct
10 Correct 39 ms 63616 KB Output is correct
11 Correct 38 ms 63616 KB Output is correct
12 Correct 38 ms 63616 KB Output is correct
13 Correct 38 ms 63608 KB Output is correct
14 Correct 38 ms 63608 KB Output is correct
15 Correct 38 ms 63608 KB Output is correct
16 Correct 38 ms 63616 KB Output is correct
17 Correct 38 ms 63612 KB Output is correct
18 Correct 38 ms 63608 KB Output is correct
19 Correct 38 ms 63608 KB Output is correct
20 Correct 38 ms 63608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 63616 KB Output is correct
2 Correct 38 ms 63608 KB Output is correct
3 Correct 38 ms 63616 KB Output is correct
4 Correct 38 ms 63616 KB Output is correct
5 Correct 38 ms 63608 KB Output is correct
6 Correct 39 ms 63616 KB Output is correct
7 Correct 38 ms 63616 KB Output is correct
8 Correct 38 ms 63608 KB Output is correct
9 Correct 38 ms 63616 KB Output is correct
10 Correct 39 ms 63616 KB Output is correct
11 Correct 38 ms 63616 KB Output is correct
12 Correct 38 ms 63616 KB Output is correct
13 Correct 38 ms 63608 KB Output is correct
14 Correct 38 ms 63608 KB Output is correct
15 Correct 38 ms 63608 KB Output is correct
16 Correct 38 ms 63616 KB Output is correct
17 Correct 38 ms 63612 KB Output is correct
18 Correct 38 ms 63608 KB Output is correct
19 Correct 38 ms 63608 KB Output is correct
20 Correct 38 ms 63608 KB Output is correct
21 Execution timed out 5 ms 512 KB Time limit exceeded (wall clock)
22 Halted 0 ms 0 KB -