답안 #447170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447170 2021-07-24T20:58:31 Z FEDIKUS Cigle (COI21_cigle) C++17
100 / 100
368 ms 98500 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,int) sort(a.begin(),a.end(),greater<int>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define up(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define vstart auto startt=chrono::system_clock::now()
#define vend auto endd=chrono::system_clock::now()
#define vvreme chrono::duration<double> vremee=endd-startt
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef string str;

const int maxn=5e3+10;
int niz[maxn];
int dp[maxn][maxn];

void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>niz[i];
    for(int i=1;i<=n;i++){
        for(int j=n;j>=0;j--){
            dp[i][j]=max(dp[i][j],dp[i][j+1]);
        }
        int tren=i;
        int sum1=0;
        int sum2=0;
        int koliko=0;
        int maxi=0;
        for(int j=i+1;j<=n;j++){
            sum1+=niz[j];
            while(tren>=1 && sum2<sum1){
                sum2+=niz[tren];
                tren--;
                maxi=max(maxi,koliko+dp[i][i-tren]);
            }
            dp[j][j-i]=max(dp[j][j-i],maxi);
            if(sum1==sum2) koliko++;
        }
    }
    cout<<dp[n][0];
}

int main(){
    ios;
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 572 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 572 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3276 KB Output is correct
2 Correct 4 ms 3276 KB Output is correct
3 Correct 4 ms 3276 KB Output is correct
4 Correct 4 ms 3268 KB Output is correct
5 Correct 4 ms 3276 KB Output is correct
6 Correct 5 ms 3276 KB Output is correct
7 Correct 4 ms 3276 KB Output is correct
8 Correct 4 ms 3276 KB Output is correct
9 Correct 4 ms 3276 KB Output is correct
10 Correct 5 ms 3276 KB Output is correct
11 Correct 4 ms 3276 KB Output is correct
12 Correct 5 ms 3276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 572 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 572 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 4 ms 3276 KB Output is correct
22 Correct 4 ms 3276 KB Output is correct
23 Correct 4 ms 3276 KB Output is correct
24 Correct 4 ms 3268 KB Output is correct
25 Correct 4 ms 3276 KB Output is correct
26 Correct 5 ms 3276 KB Output is correct
27 Correct 4 ms 3276 KB Output is correct
28 Correct 4 ms 3276 KB Output is correct
29 Correct 4 ms 3276 KB Output is correct
30 Correct 5 ms 3276 KB Output is correct
31 Correct 4 ms 3276 KB Output is correct
32 Correct 5 ms 3276 KB Output is correct
33 Correct 4 ms 3276 KB Output is correct
34 Correct 5 ms 3276 KB Output is correct
35 Correct 4 ms 3276 KB Output is correct
36 Correct 4 ms 3276 KB Output is correct
37 Correct 4 ms 3276 KB Output is correct
38 Correct 4 ms 3276 KB Output is correct
39 Correct 5 ms 3276 KB Output is correct
40 Correct 5 ms 3276 KB Output is correct
41 Correct 5 ms 3276 KB Output is correct
42 Correct 4 ms 3276 KB Output is correct
43 Correct 4 ms 3276 KB Output is correct
44 Correct 4 ms 3276 KB Output is correct
45 Correct 5 ms 3276 KB Output is correct
46 Correct 4 ms 3276 KB Output is correct
47 Correct 4 ms 3276 KB Output is correct
48 Correct 4 ms 3264 KB Output is correct
49 Correct 4 ms 3276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 572 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 572 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 4 ms 3276 KB Output is correct
22 Correct 4 ms 3276 KB Output is correct
23 Correct 4 ms 3276 KB Output is correct
24 Correct 4 ms 3268 KB Output is correct
25 Correct 4 ms 3276 KB Output is correct
26 Correct 5 ms 3276 KB Output is correct
27 Correct 4 ms 3276 KB Output is correct
28 Correct 4 ms 3276 KB Output is correct
29 Correct 4 ms 3276 KB Output is correct
30 Correct 5 ms 3276 KB Output is correct
31 Correct 4 ms 3276 KB Output is correct
32 Correct 5 ms 3276 KB Output is correct
33 Correct 4 ms 3276 KB Output is correct
34 Correct 5 ms 3276 KB Output is correct
35 Correct 4 ms 3276 KB Output is correct
36 Correct 4 ms 3276 KB Output is correct
37 Correct 4 ms 3276 KB Output is correct
38 Correct 4 ms 3276 KB Output is correct
39 Correct 5 ms 3276 KB Output is correct
40 Correct 5 ms 3276 KB Output is correct
41 Correct 5 ms 3276 KB Output is correct
42 Correct 4 ms 3276 KB Output is correct
43 Correct 4 ms 3276 KB Output is correct
44 Correct 4 ms 3276 KB Output is correct
45 Correct 5 ms 3276 KB Output is correct
46 Correct 4 ms 3276 KB Output is correct
47 Correct 4 ms 3276 KB Output is correct
48 Correct 4 ms 3264 KB Output is correct
49 Correct 4 ms 3276 KB Output is correct
50 Correct 345 ms 98316 KB Output is correct
51 Correct 344 ms 98364 KB Output is correct
52 Correct 339 ms 98460 KB Output is correct
53 Correct 340 ms 98376 KB Output is correct
54 Correct 359 ms 98392 KB Output is correct
55 Correct 362 ms 98264 KB Output is correct
56 Correct 343 ms 98388 KB Output is correct
57 Correct 345 ms 98484 KB Output is correct
58 Correct 353 ms 98288 KB Output is correct
59 Correct 354 ms 98392 KB Output is correct
60 Correct 351 ms 98500 KB Output is correct
61 Correct 368 ms 98372 KB Output is correct
62 Correct 344 ms 98432 KB Output is correct
63 Correct 352 ms 98272 KB Output is correct
64 Correct 347 ms 98360 KB Output is correct
65 Correct 349 ms 98380 KB Output is correct
66 Correct 346 ms 98328 KB Output is correct
67 Correct 344 ms 98384 KB Output is correct
68 Correct 340 ms 98288 KB Output is correct
69 Correct 339 ms 98292 KB Output is correct
70 Correct 350 ms 98292 KB Output is correct
71 Correct 348 ms 98372 KB Output is correct
72 Correct 352 ms 98300 KB Output is correct