답안 #755198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755198 2023-06-09T14:46:15 Z Lucpp Mizuyokan 2 (JOI23_mizuyokan2) C++17
28 / 100
4000 ms 9260 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int DIST = 60;

int solve(vector<ll> v){
    int n = (int)v.size();
    vector<int> dp(n);
    dp[0] = 1;
    for(int i = 1; i < n; i++){
        ll sum = 0;
        for(int j = i-1; j >= max(0, i-DIST); j--){
            sum += v[j];
            if(sum > v[i]){
                if(j == 0) dp[i] = max(dp[i], 2);
                else if(sum > v[j-1]) dp[i] = max(dp[i], dp[j-1] + 2);
            }
        }
    }
    int ans = max(1, dp[n-1]);
    ll sum = 0;
    for(int i = n-1; i >= 1; i--){
        sum += v[i];
        if(sum > v[i-1]) ans = max(ans, dp[i-1]+1);
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, Q;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    cin >> Q;
    for(int q = 0; q < Q; q++){
        int x, a, b;
        ll y;
        cin >> x >> y >> a >> b;
        x--;
        v[x] = y;
        vector<ll> w;
        for(int i = a; i < b; i++) w.push_back(v[i]);
        cout << solve(w) << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
14 Correct 1 ms 316 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 320 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
14 Correct 1 ms 316 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 320 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 324 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 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 3 ms 328 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 1 ms 328 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 324 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 2 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
14 Correct 1 ms 316 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 320 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 324 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 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 3 ms 328 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 1 ms 328 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 324 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 2 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 26 ms 3916 KB Output is correct
42 Correct 28 ms 4312 KB Output is correct
43 Correct 29 ms 4300 KB Output is correct
44 Correct 22 ms 3672 KB Output is correct
45 Correct 71 ms 6912 KB Output is correct
46 Correct 172 ms 8516 KB Output is correct
47 Correct 136 ms 6732 KB Output is correct
48 Correct 204 ms 8776 KB Output is correct
49 Correct 253 ms 8660 KB Output is correct
50 Correct 168 ms 7060 KB Output is correct
51 Correct 156 ms 8460 KB Output is correct
52 Correct 122 ms 6900 KB Output is correct
53 Correct 257 ms 9260 KB Output is correct
54 Correct 232 ms 8144 KB Output is correct
55 Correct 185 ms 8352 KB Output is correct
56 Correct 159 ms 6640 KB Output is correct
57 Correct 115 ms 5892 KB Output is correct
58 Correct 174 ms 8000 KB Output is correct
59 Correct 54 ms 7236 KB Output is correct
60 Correct 86 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 298 ms 4868 KB Output is correct
3 Correct 2302 ms 6124 KB Output is correct
4 Execution timed out 4073 ms 4800 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 279 ms 4608 KB Output is correct
4 Correct 2327 ms 5084 KB Output is correct
5 Execution timed out 4056 ms 8120 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
14 Correct 1 ms 316 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 320 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 324 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 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 3 ms 328 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 1 ms 328 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 324 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 2 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 26 ms 3916 KB Output is correct
42 Correct 28 ms 4312 KB Output is correct
43 Correct 29 ms 4300 KB Output is correct
44 Correct 22 ms 3672 KB Output is correct
45 Correct 71 ms 6912 KB Output is correct
46 Correct 172 ms 8516 KB Output is correct
47 Correct 136 ms 6732 KB Output is correct
48 Correct 204 ms 8776 KB Output is correct
49 Correct 253 ms 8660 KB Output is correct
50 Correct 168 ms 7060 KB Output is correct
51 Correct 156 ms 8460 KB Output is correct
52 Correct 122 ms 6900 KB Output is correct
53 Correct 257 ms 9260 KB Output is correct
54 Correct 232 ms 8144 KB Output is correct
55 Correct 185 ms 8352 KB Output is correct
56 Correct 159 ms 6640 KB Output is correct
57 Correct 115 ms 5892 KB Output is correct
58 Correct 174 ms 8000 KB Output is correct
59 Correct 54 ms 7236 KB Output is correct
60 Correct 86 ms 6492 KB Output is correct
61 Correct 1 ms 324 KB Output is correct
62 Correct 298 ms 4868 KB Output is correct
63 Correct 2302 ms 6124 KB Output is correct
64 Execution timed out 4073 ms 4800 KB Time limit exceeded
65 Halted 0 ms 0 KB -