# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1059794 | 2024-08-15T08:14:09 Z | tolbi | 봉쇄 시간 (IOI23_closing) | C++17 | 1000 ms | 11344 KB |
#include "closing.h" #include <bits/stdc++.h> using namespace std; int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) { vector<long long> dp1(N); vector<long long> dp2(N); vector<long long> dp3(N); long long cur = 0; for (int i = X-1; i >= 0; i--){ cur+=W[i]; dp1[i]=cur; } cur=0; for (int i = X+1; i < N; i++){ cur+=W[i-1]; dp1[i]=cur; } cur = 0; for (int i = Y-1; i >= 0; i--){ cur+=W[i]; dp2[i]=cur; } cur=0; for (int i = Y+1; i < N; i++){ cur+=W[i-1]; dp2[i]=cur; } for (int i = 0; i < N; i++){ dp3[i]=max(dp1[i],dp2[i]); if (i) dp3[i]+=dp3[i-1]; } int ans = 0; for (int l = 0; l <= Y; l++){ for (int r = max(X,l); r < N; r++){ long long cur = dp3[r]; if (l) cur-=dp3[l-1]; if (cur>K) break; int rbound = N-1; for (int j = r+1; j < N; j++){ cur+=dp2[j]; } for (int j = l-1; j >= 0; j--){ cur+=dp1[j]; while (cur>K){ if (rbound==r) break; cur-=dp2[rbound]; rbound--; if (rbound==r) break; } if (cur>K) break; if (cur<=K && rbound>=Y && j<=X){ ans=max(ans,rbound-l+1+r-j+1); } } } } vector<long long> pref = dp2; for (int i = 1; i < pref.size(); i++){ pref[i]+=pref[i-1]; } function<long long(int,int)> query = [&](int l, int r)->long long{ if (l>r) return 0; long long hh = pref[r]; if (l) hh-=pref[l-1]; return hh; }; for (int a = 0; a <= X; a++){ for (int b = Y; b < N; b++){ long long cur = 0; for (int i = a; i <= X; i++){ cur+=dp1[i]; } for (int i = Y; i <= b; i++){ cur+=dp2[i]; } if (cur>K) continue; for (int rv = a; rv < b; rv++){ if (cur>K) break; int l = rv+1, r = b; while (l<r){ int mid = l+(r-l)/2; if (query(mid,b-1)+cur<=K){ r=mid; } else l=mid+1; } ans=max(ans,rv-a+1+b-l+1); cur+=dp1[rv+1]; } } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1026 ms | 11344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Incorrect | 1 ms | 348 KB | 10th lines differ - on the 1st token, expected: '34', found: '33' |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Incorrect | 1 ms | 348 KB | 10th lines differ - on the 1st token, expected: '34', found: '33' |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | 1st lines differ - on the 1st token, expected: '6', found: '5' |
2 | Halted | 0 ms | 0 KB | - |