Submission #287857

# Submission time Handle Problem Language Result Execution time Memory
287857 2020-09-01T04:55:45 Z dantoh000 Bigger segments (IZhO19_segments) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,ll> ii;

int n;
int a[500005];
ii dp[500005];
ll p[500005];
int main(){
    scanf("%d",&n);
    for (int i = 1 ; i <= n; i++){
        a[i] = rand()%1000;
        //scanf("%d",&a[i]);
        p[i] = p[i-1]+a[i];
    }
    dp[0] = ii(0,0);
    for (int i = 1; i <= n; i++){
        for (int j = i-1; j >= 0; j--){
            if (dp[j].fi < dp[i-1].fi-1) break;
            if (p[i]-p[j] >= dp[j].se){
                if (dp[i].fi < dp[j].fi+1 || (dp[i].fi == dp[j].fi+1 && dp[i].se > p[i]-p[j]) ){
                    dp[i] = {dp[j].fi+1, p[i]-p[j]};
                }
            }
        }
        printf("%d ", dp[i].fi);
    }

    //printf("%d\n",dp[n].fi);
}

Compilation message

segments.cpp: In function 'int main()':
segments.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -