Submission #781186

# Submission time Handle Problem Language Result Execution time Memory
781186 2023-07-12T21:57:37 Z AdamGS Mizuyokan 2 (JOI23_mizuyokan2) C++17
6 / 100
3624 ms 7356 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e9+7;
const int LIM=207;
int dp[LIM][LIM][2];
ll sum[LIM];
ll cnt(int l, int r) {
	return sum[r]-(l?sum[l-1]:0);
}
int solve(vector<ll>T) {
	int n=T.size();
	rep(i, n) {
		sum[i]=T[i];
		if(i) sum[i]+=sum[i-1];
	}
	rep(i, n) rep(j, n) rep(l, 2) dp[i][j][l]=-INF;
	rep(r, n) rep(l, r+1) {
		if(l==0) {
			dp[l][r][0]=dp[l][r][1]=1;
			continue;
		}
		rep(i, l) {
			if(cnt(i, l-1)>cnt(l, r)) dp[l][r][0]=max(dp[l][r][0], dp[i][l-1][1]+1);
			else if(cnt(i, l-1)<cnt(l, r)) dp[l][r][1]=max(dp[l][r][1], dp[i][l-1][0]+1);
		}
	}
	int ans=0;
	rep(i, n) rep(j, 2) ans=max(ans, dp[i][n-1][j]);
	return ans;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	vector<ll>T(n);
	rep(i, n) cin >> T[i];
	int q;
	cin >> q;
	while(q--) {
		ll x, y, a, b;
		cin >> x >> y >> a >> b; --x; --b;
		T[x]=y;
		vector<ll>P;
		while(a<=b) {
			P.pb(T[a]);
			++a;
		}
		cout << solve(P) << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 456 KB Output is correct
4 Correct 14 ms 664 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 8 ms 584 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 3 ms 452 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 456 KB Output is correct
4 Correct 14 ms 664 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 8 ms 584 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 3 ms 452 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Runtime error 12 ms 1128 KB Execution killed with signal 11
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 456 KB Output is correct
4 Correct 14 ms 664 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 8 ms 584 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 3 ms 452 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Runtime error 12 ms 1128 KB Execution killed with signal 11
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 3624 ms 5132 KB Output is correct
3 Runtime error 22 ms 7356 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3467 ms 5004 KB Output is correct
4 Runtime error 19 ms 6464 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 456 KB Output is correct
4 Correct 14 ms 664 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 8 ms 584 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 3 ms 452 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Runtime error 12 ms 1128 KB Execution killed with signal 11
24 Halted 0 ms 0 KB -