답안 #530389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530389 2022-02-25T09:26:29 Z jiahng Cigle (COI21_cigle) C++14
48 / 100
1000 ms 292344 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<int,int> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define maxn 5001
//~ #define getchar_unlocked _getchar_nolock

int N,D[maxn],ss[maxn];

inline int readInt() {
    int x = 0;
    char ch = getchar_unlocked();
    while (ch < '0' || ch > '9') ch = getchar_unlocked();
    while (ch >= '0' && ch <= '9'){
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar_unlocked();
	}
    return x;
}

vpi A[maxn];
int dp[maxn][maxn],R[maxn][maxn];
int32_t main() {
    fast;
    N = readInt();
    FOR(i,1,N){
		D[i] = readInt();
		ss[i] = ss[i-1] + D[i];
	}
    mem(R, -1);
	FOR(l,2,N) FOR(r,l+1,N-1) if ((ss[l-1] + ss[r]) % 2 == 0){
		int ssb = (ss[l-1] + ss[r]) / 2;
		int b = lower_bound(ss+l,ss+r,ssb) - ss;
		if (ss[b] == ssb ){
			//~ cout << l-1 << ' ' << b << ' ' << r << '\n';
			A[b].pb(pi(l-1,r));
		}
	}
	FOR(i,1,N) sort(all(A[i]), greater <pi>());
	
	
	DEC(i,N,1) FOR(j,0,i-1) {
		dp[i][j] = dp[i+1][j];
		FOR(k,0,A[i].size()-1){
			if (A[i][k].f > j){
				dp[i][j] = max(dp[i][j], dp[max(i, A[i][k].s+1)][i] + k + 1);
			}else break;
		}
	}
	cout << dp[1][0];
	
}	

# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 196232 KB Output is correct
2 Correct 73 ms 196208 KB Output is correct
3 Correct 74 ms 196272 KB Output is correct
4 Correct 73 ms 196164 KB Output is correct
5 Correct 83 ms 196276 KB Output is correct
6 Correct 73 ms 196232 KB Output is correct
7 Correct 71 ms 196168 KB Output is correct
8 Correct 72 ms 196280 KB Output is correct
9 Correct 81 ms 196256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 196232 KB Output is correct
2 Correct 73 ms 196208 KB Output is correct
3 Correct 74 ms 196272 KB Output is correct
4 Correct 73 ms 196164 KB Output is correct
5 Correct 83 ms 196276 KB Output is correct
6 Correct 73 ms 196232 KB Output is correct
7 Correct 71 ms 196168 KB Output is correct
8 Correct 72 ms 196280 KB Output is correct
9 Correct 81 ms 196256 KB Output is correct
10 Correct 74 ms 196532 KB Output is correct
11 Correct 74 ms 196472 KB Output is correct
12 Correct 73 ms 196564 KB Output is correct
13 Correct 77 ms 196552 KB Output is correct
14 Correct 74 ms 196492 KB Output is correct
15 Correct 73 ms 196588 KB Output is correct
16 Correct 81 ms 196852 KB Output is correct
17 Correct 75 ms 196448 KB Output is correct
18 Correct 74 ms 196520 KB Output is correct
19 Correct 74 ms 196512 KB Output is correct
20 Correct 72 ms 196444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 199884 KB Output is correct
2 Correct 105 ms 200292 KB Output is correct
3 Correct 93 ms 200028 KB Output is correct
4 Correct 98 ms 200024 KB Output is correct
5 Correct 98 ms 200108 KB Output is correct
6 Correct 101 ms 200244 KB Output is correct
7 Correct 99 ms 200140 KB Output is correct
8 Correct 97 ms 200116 KB Output is correct
9 Correct 103 ms 200156 KB Output is correct
10 Correct 105 ms 200084 KB Output is correct
11 Correct 98 ms 199976 KB Output is correct
12 Correct 102 ms 199964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 196232 KB Output is correct
2 Correct 73 ms 196208 KB Output is correct
3 Correct 74 ms 196272 KB Output is correct
4 Correct 73 ms 196164 KB Output is correct
5 Correct 83 ms 196276 KB Output is correct
6 Correct 73 ms 196232 KB Output is correct
7 Correct 71 ms 196168 KB Output is correct
8 Correct 72 ms 196280 KB Output is correct
9 Correct 81 ms 196256 KB Output is correct
10 Correct 74 ms 196532 KB Output is correct
11 Correct 74 ms 196472 KB Output is correct
12 Correct 73 ms 196564 KB Output is correct
13 Correct 77 ms 196552 KB Output is correct
14 Correct 74 ms 196492 KB Output is correct
15 Correct 73 ms 196588 KB Output is correct
16 Correct 81 ms 196852 KB Output is correct
17 Correct 75 ms 196448 KB Output is correct
18 Correct 74 ms 196520 KB Output is correct
19 Correct 74 ms 196512 KB Output is correct
20 Correct 72 ms 196444 KB Output is correct
21 Correct 100 ms 199884 KB Output is correct
22 Correct 105 ms 200292 KB Output is correct
23 Correct 93 ms 200028 KB Output is correct
24 Correct 98 ms 200024 KB Output is correct
25 Correct 98 ms 200108 KB Output is correct
26 Correct 101 ms 200244 KB Output is correct
27 Correct 99 ms 200140 KB Output is correct
28 Correct 97 ms 200116 KB Output is correct
29 Correct 103 ms 200156 KB Output is correct
30 Correct 105 ms 200084 KB Output is correct
31 Correct 98 ms 199976 KB Output is correct
32 Correct 102 ms 199964 KB Output is correct
33 Correct 92 ms 199860 KB Output is correct
34 Correct 101 ms 200056 KB Output is correct
35 Correct 93 ms 199984 KB Output is correct
36 Correct 115 ms 200172 KB Output is correct
37 Correct 100 ms 200084 KB Output is correct
38 Correct 118 ms 200132 KB Output is correct
39 Correct 82 ms 199472 KB Output is correct
40 Correct 78 ms 199144 KB Output is correct
41 Correct 75 ms 199160 KB Output is correct
42 Correct 81 ms 199200 KB Output is correct
43 Correct 81 ms 199192 KB Output is correct
44 Correct 82 ms 199140 KB Output is correct
45 Correct 87 ms 199196 KB Output is correct
46 Correct 90 ms 199144 KB Output is correct
47 Correct 84 ms 199176 KB Output is correct
48 Correct 79 ms 199184 KB Output is correct
49 Correct 78 ms 199244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 196232 KB Output is correct
2 Correct 73 ms 196208 KB Output is correct
3 Correct 74 ms 196272 KB Output is correct
4 Correct 73 ms 196164 KB Output is correct
5 Correct 83 ms 196276 KB Output is correct
6 Correct 73 ms 196232 KB Output is correct
7 Correct 71 ms 196168 KB Output is correct
8 Correct 72 ms 196280 KB Output is correct
9 Correct 81 ms 196256 KB Output is correct
10 Correct 74 ms 196532 KB Output is correct
11 Correct 74 ms 196472 KB Output is correct
12 Correct 73 ms 196564 KB Output is correct
13 Correct 77 ms 196552 KB Output is correct
14 Correct 74 ms 196492 KB Output is correct
15 Correct 73 ms 196588 KB Output is correct
16 Correct 81 ms 196852 KB Output is correct
17 Correct 75 ms 196448 KB Output is correct
18 Correct 74 ms 196520 KB Output is correct
19 Correct 74 ms 196512 KB Output is correct
20 Correct 72 ms 196444 KB Output is correct
21 Correct 100 ms 199884 KB Output is correct
22 Correct 105 ms 200292 KB Output is correct
23 Correct 93 ms 200028 KB Output is correct
24 Correct 98 ms 200024 KB Output is correct
25 Correct 98 ms 200108 KB Output is correct
26 Correct 101 ms 200244 KB Output is correct
27 Correct 99 ms 200140 KB Output is correct
28 Correct 97 ms 200116 KB Output is correct
29 Correct 103 ms 200156 KB Output is correct
30 Correct 105 ms 200084 KB Output is correct
31 Correct 98 ms 199976 KB Output is correct
32 Correct 102 ms 199964 KB Output is correct
33 Correct 92 ms 199860 KB Output is correct
34 Correct 101 ms 200056 KB Output is correct
35 Correct 93 ms 199984 KB Output is correct
36 Correct 115 ms 200172 KB Output is correct
37 Correct 100 ms 200084 KB Output is correct
38 Correct 118 ms 200132 KB Output is correct
39 Correct 82 ms 199472 KB Output is correct
40 Correct 78 ms 199144 KB Output is correct
41 Correct 75 ms 199160 KB Output is correct
42 Correct 81 ms 199200 KB Output is correct
43 Correct 81 ms 199192 KB Output is correct
44 Correct 82 ms 199140 KB Output is correct
45 Correct 87 ms 199196 KB Output is correct
46 Correct 90 ms 199144 KB Output is correct
47 Correct 84 ms 199176 KB Output is correct
48 Correct 79 ms 199184 KB Output is correct
49 Correct 78 ms 199244 KB Output is correct
50 Execution timed out 1084 ms 292344 KB Time limit exceeded
51 Halted 0 ms 0 KB -