답안 #707737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707737 2023-03-09T23:46:22 Z arcane Cigle (COI21_cigle) C++17
0 / 100
1000 ms 2240 KB
#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;
}

Compilation message

cigle.cpp: In function 'int32_t main()':
cigle.cpp:12:14: warning: unused variable 'pref' [-Wunused-variable]
   12 |  int arr[n], pref[n], dp[n][n];
      |              ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
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 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 2240 KB Time limit exceeded
2 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 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
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 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -