Submission #299741

# Submission time Handle Problem Language Result Execution time Memory
299741 2020-09-15T14:43:06 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,int> ii;
typedef pair<ll, int> li;
ii dp[500005];
int n;
ll p[500005];
priority_queue<li ,vector<li>, greater<li> > pq;
int main(){
    scanf("%d",&n);
    pq.push({0,0});
    for (int i = 1; i <= n; i++){
        scanf("%lld",&p[i]);
        p[i]+=p[i-1];
        li cur;
        while (pq.size() && pq.top().first <= p[i]) {
            cur = pq.top(); pq.pop();
        }
        pq.push(cur);
        //printf("%d: can get %d %d (%d,%d)\n",p[i],pq.top().fi, pq.top().se, dp[pq.top().se].fi, dp[pq.top().se].se);
        dp[i].fi = dp[pq.top().se].fi + 1;
        dp[i].se = pq.top().se;
        //printf("pushing (%d,%d)\n",2*p[i]-p[dp[i].se], i);
        pq.push({2*p[i]-p[dp[i].se], i});
    }
    printf("%d",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);
      |     ~~~~~^~~~~~~~~
segments.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |         scanf("%lld",&p[i]);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 1 ms 384 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 1 ms 384 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 1 ms 384 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 1 ms 384 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 1 ms 384 KB Output isn't correct
11 Halted 0 ms 0 KB -