답안 #535669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535669 2022-03-10T21:42:15 Z MOUF_MAHMALAT Cigle (COI21_cigle) C++14
48 / 100
1000 ms 1452 KB
#include<bits/stdc++.h>
#define all(s) s.begin(),s.end()
#define F first
#define S second
using namespace std;
typedef int ll;
ll n,a[5009],dp[509][509],p[5009],ans;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        cin>>a[i];
        p[i]=p[i-1]+a[i];
    }
    for(ll i=2; i<=n; i++)
    {
        for(ll j=i; j<=n; j++)
        {
            ll sum=0,l=i;
            dp[i][j]=dp[i-1][i-1];
            for(ll k=i-2; k; k--)
            {
                if(i==j)
                {
                    dp[i][j]=max(dp[i][j],dp[k][i-1]);
                    continue;
                }
                while((p[l]-p[i-1]<p[i-1]-p[k])&&(l<j-1))
                    l++;
                if(p[l]-p[i-1]==p[i-1]-p[k])
                    sum++;
                dp[i][j]=max(dp[i][j],dp[k][i-1]+sum);
            }
        }
    }
    for(ll i=1; i<=n; i++)
        ans=max(ans,dp[i][n]);
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 456 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 1284 KB Output is correct
2 Correct 77 ms 1320 KB Output is correct
3 Correct 80 ms 1196 KB Output is correct
4 Correct 74 ms 1304 KB Output is correct
5 Correct 75 ms 1256 KB Output is correct
6 Correct 73 ms 1232 KB Output is correct
7 Correct 70 ms 1192 KB Output is correct
8 Correct 74 ms 1336 KB Output is correct
9 Correct 71 ms 1308 KB Output is correct
10 Correct 72 ms 1348 KB Output is correct
11 Correct 71 ms 1296 KB Output is correct
12 Correct 70 ms 1232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 456 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 73 ms 1284 KB Output is correct
22 Correct 77 ms 1320 KB Output is correct
23 Correct 80 ms 1196 KB Output is correct
24 Correct 74 ms 1304 KB Output is correct
25 Correct 75 ms 1256 KB Output is correct
26 Correct 73 ms 1232 KB Output is correct
27 Correct 70 ms 1192 KB Output is correct
28 Correct 74 ms 1336 KB Output is correct
29 Correct 71 ms 1308 KB Output is correct
30 Correct 72 ms 1348 KB Output is correct
31 Correct 71 ms 1296 KB Output is correct
32 Correct 70 ms 1232 KB Output is correct
33 Correct 70 ms 1264 KB Output is correct
34 Correct 72 ms 1236 KB Output is correct
35 Correct 70 ms 1244 KB Output is correct
36 Correct 73 ms 1316 KB Output is correct
37 Correct 76 ms 1308 KB Output is correct
38 Correct 71 ms 1312 KB Output is correct
39 Correct 73 ms 1364 KB Output is correct
40 Correct 71 ms 1240 KB Output is correct
41 Correct 74 ms 1316 KB Output is correct
42 Correct 72 ms 1256 KB Output is correct
43 Correct 72 ms 1224 KB Output is correct
44 Correct 71 ms 1232 KB Output is correct
45 Correct 74 ms 1452 KB Output is correct
46 Correct 70 ms 1220 KB Output is correct
47 Correct 72 ms 1272 KB Output is correct
48 Correct 73 ms 1240 KB Output is correct
49 Correct 73 ms 1240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 456 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 73 ms 1284 KB Output is correct
22 Correct 77 ms 1320 KB Output is correct
23 Correct 80 ms 1196 KB Output is correct
24 Correct 74 ms 1304 KB Output is correct
25 Correct 75 ms 1256 KB Output is correct
26 Correct 73 ms 1232 KB Output is correct
27 Correct 70 ms 1192 KB Output is correct
28 Correct 74 ms 1336 KB Output is correct
29 Correct 71 ms 1308 KB Output is correct
30 Correct 72 ms 1348 KB Output is correct
31 Correct 71 ms 1296 KB Output is correct
32 Correct 70 ms 1232 KB Output is correct
33 Correct 70 ms 1264 KB Output is correct
34 Correct 72 ms 1236 KB Output is correct
35 Correct 70 ms 1244 KB Output is correct
36 Correct 73 ms 1316 KB Output is correct
37 Correct 76 ms 1308 KB Output is correct
38 Correct 71 ms 1312 KB Output is correct
39 Correct 73 ms 1364 KB Output is correct
40 Correct 71 ms 1240 KB Output is correct
41 Correct 74 ms 1316 KB Output is correct
42 Correct 72 ms 1256 KB Output is correct
43 Correct 72 ms 1224 KB Output is correct
44 Correct 71 ms 1232 KB Output is correct
45 Correct 74 ms 1452 KB Output is correct
46 Correct 70 ms 1220 KB Output is correct
47 Correct 72 ms 1272 KB Output is correct
48 Correct 73 ms 1240 KB Output is correct
49 Correct 73 ms 1240 KB Output is correct
50 Execution timed out 1082 ms 1220 KB Time limit exceeded
51 Halted 0 ms 0 KB -