Submission #171570

# Submission time Handle Problem Language Result Execution time Memory
171570 2019-12-29T08:58:46 Z juggernaut Bootfall (IZhO17_bootfall) C++14
0 / 100
5 ms 632 KB
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,a[500],dp[250001],i,j,sum,mx=250000;
bool can[250001];
void add(int v){
    for(int j=sum;j>=0;j--)dp[j+v]+=dp[j];
    sum+=v;
}
void del(int v){
    sum-=v;
    for(int j=0;j<=sum;j++)dp[j+v]-=dp[j];
}
vector<int>ans;
main(){
    dp[0]=1;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
        add(a[i]);
    }
    for(i=0;i<n;i++){
        del(a[i]);
        for(j=1;j<=mx;j++)if(((sum+j)&1)||!dp[(sum+j)/2])can[j]=1;
        add(a[i]);
    }
    for(i=1;i<=mx;i++)if(!can[i])ans.push_back(i);
    printf("%lld\n",(int)ans.size());
    for(auto res:ans)printf("%lld ",res);
}

Compilation message

bootfall.cpp:16:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
bootfall.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Incorrect 4 ms 632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Incorrect 4 ms 632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Incorrect 4 ms 632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Incorrect 4 ms 632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Incorrect 4 ms 632 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Incorrect 4 ms 632 KB Output isn't correct
4 Halted 0 ms 0 KB -