# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
420409 | 2021-06-08T10:53:15 Z | Nicholas_Patrick | Cigle (COI21_cigle) | C++17 | 1000 ms | 1228 KB |
#include <cstdio> #include <queue> #include <algorithm> using namespace std; int main(){ int n; scanf("%d", &n); vector<int> d(n); for(int& i : d) scanf("%d", &i); vector<vector<int>> dp(n, vector<int>(n, 0)); /* dp[x][y] x: last brick laid y: earliest brick in last row y≤x */ for(int i=1; i<n; i++){ vector<int> suffsum, prefsum; for(int j=i; j--;){ if(suffsum.empty()){ suffsum.push_back(d[j]); }else{ suffsum.push_back(d[j]+suffsum.back()); } } for(int j=i; j<n; j++){ if(prefsum.empty()){ prefsum.push_back(d[j]); }else{ prefsum.push_back(d[j]+prefsum.back()); } } for(int j=0, k=0, matches=0; j<prefsum.size(); j++){ while(k+1<suffsum.size() and suffsum[k]<prefsum[j]) k++; if(prefsum[j]==suffsum[k]){ matches++; //dp transition found if(i+j+1<n) for(int p=0; p<i; p++)for(int q=0; q<i-k-1; q++) dp[i+j+1][i]=max(dp[i+j+1][i], dp[p][q]+matches); } } } int ans=0; for(auto& i : dp) ans=max(ans, *max_element(i.begin(), i.end())); printf("%d\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 280 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 272 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 280 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 272 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 2 ms | 204 KB | Output is correct |
11 | Correct | 2 ms | 204 KB | Output is correct |
12 | Correct | 2 ms | 312 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 2 ms | 204 KB | Output is correct |
15 | Correct | 3 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 312 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1079 ms | 1228 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 280 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 272 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 2 ms | 204 KB | Output is correct |
11 | Correct | 2 ms | 204 KB | Output is correct |
12 | Correct | 2 ms | 312 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 2 ms | 204 KB | Output is correct |
15 | Correct | 3 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 312 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Execution timed out | 1079 ms | 1228 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 280 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 272 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 2 ms | 204 KB | Output is correct |
11 | Correct | 2 ms | 204 KB | Output is correct |
12 | Correct | 2 ms | 312 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 2 ms | 204 KB | Output is correct |
15 | Correct | 3 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 312 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Execution timed out | 1079 ms | 1228 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |