답안 #180306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
180306 2020-01-08T20:05:38 Z rzbt Bigger segments (IZhO19_segments) C++14
0 / 100
13 ms 376 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 500005
typedef long long ll;


using namespace std;

ll n;
ll mz=0;
ll tz=0;

ll niz[MAXN];
pair<ll,ll> dp[MAXN];
ll pref[MAXN];
ll res[MAXN];
set<pair<ll,ll> > s;

int main()
{
    scanf("%lld", &n);
    for(ll i=1;i<=n;i++){
        scanf("%lld",niz+i);
        pref[i]=pref[i-1]+niz[i];
    }
    //dp[i]=mp(pref[i],1);
    for(ll i=1;i<=n;i++){
        ll dokle=0;
        //if(!s.empty())printf("    %d %d\n")
        while(!s.empty() && s.begin()->F<=pref[i]){

            dokle=max(dokle,s.begin()->S);
            s.erase(s.begin());
        }
        //printf("%lld %lld\n",i,dokle);
        dp[i]=mp(pref[i]-pref[dokle],res[dokle]+1);
        res[i]=max(res[i-1],dp[i].S);
        s.insert(mp(dp[i].F+pref[i],i));

    }

    printf("%lld",res[n]);

    return 0;
}

Compilation message

segments.cpp: In function 'int main()':
segments.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &n);
     ~~~~~^~~~~~~~~~~~
segments.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",niz+i);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Incorrect 13 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Incorrect 13 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Incorrect 13 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Incorrect 13 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Incorrect 13 ms 376 KB Output isn't correct
10 Halted 0 ms 0 KB -