# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
707737 | arcane | Cigle (COI21_cigle) | C++17 | 1087 ms | 2240 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, tot, cnt, ans = 0; cin >> n;
int arr[n], pref[n], dp[n][n];
for (int i = 0; i < n; i++) fill(dp[i], dp[i] + n, 0);
for (int i = 0; i < n; i++) cin >> arr[i];
for (int s = 0; s < n; s++){
for (int e = s; e < n; e++){
if (s == 0) dp[s][e] = 0;
else{
set <int> se; tot = arr[s]; cnt = 0;
for (int i = s + 1; i <= e; i++){
se.insert(tot);
tot += arr[i];
}
tot = 0;
for (int i = s - 1; i >= 0; i--){
dp[s][e] = max(dp[s][e], dp[i][s] + cnt);
tot += arr[i];
if (se.find(tot) != se.end()) cnt += 1;
}
}
}
}
for (int i = 0; i < n; i++) ans = max(ans, dp[i][n - 1]);
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |