답안 #781190

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781190 2023-07-12T22:12:45 Z AdamGS Mizuyokan 2 (JOI23_mizuyokan2) C++17
15 / 100
3154 ms 6752 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=2007;
int dp[LIM];
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];
		dp[i]=-INF;
	}
	dp[0]=1;
	for(int i=1; i<n; ++i) {
		if(cnt(0, i-1)>T[i]) dp[i]=2;
		rep(j, i-1) if(cnt(j+1, i-1)>max(T[i], T[j])) dp[i]=max(dp[i], dp[j]+2);
	}
	int ans=max(1, dp[n-1]);
	rep(i, n-1) if(T[i]<cnt(i+1, n-1)) ans=max(ans, dp[i]+1);
	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';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 5 ms 340 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 6 ms 336 KB Output is correct
30 Correct 4 ms 340 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 4 ms 336 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 6 ms 340 KB Output is correct
38 Correct 3 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 5 ms 340 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 6 ms 336 KB Output is correct
30 Correct 4 ms 340 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 4 ms 336 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 6 ms 340 KB Output is correct
38 Correct 3 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 18 ms 3920 KB Output is correct
42 Correct 19 ms 4320 KB Output is correct
43 Runtime error 29 ms 6516 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 188 ms 1944 KB Output is correct
3 Correct 2974 ms 3744 KB Output is correct
4 Runtime error 29 ms 6752 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 161 ms 2232 KB Output is correct
4 Correct 3154 ms 3548 KB Output is correct
5 Runtime error 18 ms 6512 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 5 ms 340 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 6 ms 336 KB Output is correct
30 Correct 4 ms 340 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 4 ms 336 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 6 ms 340 KB Output is correct
38 Correct 3 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 18 ms 3920 KB Output is correct
42 Correct 19 ms 4320 KB Output is correct
43 Runtime error 29 ms 6516 KB Execution killed with signal 11
44 Halted 0 ms 0 KB -