Submission #333887

# Submission time Handle Problem Language Result Execution time Memory
333887 2020-12-08T02:10:14 Z beksultan04 Bootfall (IZhO17_bootfall) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int a[N],b[N],q[N],dp[N],n,sum;
int used[N];
void add(int x){
    int i;
    for (i=sum;i>=0;--i){
        dp[i+x]+=dp[i];
    }
    ret ;
}

void del(int x){
    int i;
    for (i=0;i<=sum;++i){
        dp[i+x]-=dp[i];
    }
    ret ;
}

main(){
    int i,j,x;
    scan1(n)
    dp[0]=1;
    for (i=1;i<=n;++i){
        scan1(q[i])
        add(q[i]);
        sum+=q[i];
    }
    for (i=1;i<=n;++i){
        del(q[i]);
        sum-=q[i];
        for (j=sum/2;j<=sum;++j){
            if (dp[j] && j*2 > sum)
                used[j*2-sum]++;
        }
        sum+=q[i];
        add(q[i]);
    }

    vector <int> ans;
    for (x=1;x<=sum;++x){
        if (used[x]==n)ans.pb(x);
    }
    cout <<ans.size()<<"\n";
    for (i=0;i<ans.size();++i){
        cout <<ans[i]<<" ";
    }
}




Compilation message

bootfall.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main(){
      |      ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:59:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (i=0;i<ans.size();++i){
      |              ~^~~~~~~~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
bootfall.cpp:36:5: note: in expansion of macro 'scan1'
   36 |     scan1(n)
      |     ^~~~~
bootfall.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
bootfall.cpp:39:9: note: in expansion of macro 'scan1'
   39 |         scan1(q[i])
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -