제출 #889047

#제출 시각아이디문제언어결과실행 시간메모리
889047HakiersCigle (COI21_cigle)C++17
20 / 100
1059 ms23016 KiB
#include <bits/stdc++.h> using namespace std; constexpr int MAXN = 5e3 + 7; constexpr int oo = 1e9; int dp[MAXN][MAXN][2]; int d[MAXN]; bool sum[MAXN*MAXN]; int res = 0; int n; int compute(int j, int k, int i, bool right){ vector<int> tmp[2]; for(int z = j; z <= i; z++) tmp[(z > k)].push_back(d[z]); reverse(tmp[0].begin(), tmp[0].end()); int actsum = 0, cnt = 0; for(int z = 0; z + 1 < tmp[0].size(); z++){ actsum += tmp[0][z]; sum[actsum] = 1; } actsum = 0; for(int z = 0; z + 1 < tmp[1].size(); z++){ actsum += tmp[1][z]; if(sum[actsum]) cnt++; } actsum = 0; for(int z = 0; z + 1 < tmp[0].size(); z++){ actsum += tmp[0][z]; sum[actsum] = 0; } if(cnt == 0) return -oo; //if(cnt > 1) cout << j << " " << k << " " << i << " " << right << " " << cnt << "\n"; return cnt; } void solve(){ for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) dp[i][j][0] = dp[i][j][1] = -oo; for(int i = 1; i <= n; i++) dp[1][i][0] = 0; for(int i = 2; i <= n; i++){ for(int k = i-1; k >= 1; k--){ for(int j = k; j >= 1; j--){ dp[k+1][i][0] = max(dp[k+1][i][0], dp[j][k][1] + compute(j, k, i, 0)); dp[k+1][i][1] = max(dp[k+1][i][1], dp[j][k][0] + compute(j, k, i, 1)); res = max({res, dp[k+1][i][0], dp[k+1][i][1]}); } } } /* for(int i = 1; i <= n; i++){ for(int k = 1; k <= n; k++){ for(int j = k-1; j <= n; j++){ for(int z = j; z < i; z++){ dp[z+1][i][k] = max(dp[z+1][i][k], dp[j][z][k-1] + compute(j, z, i, (k%2))); res = max(res, dp[z+1][i][k]); } } } } */ } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++) cin >> d[i]; solve(); cout << res << "\n"; }

컴파일 시 표준 에러 (stderr) 메시지

cigle.cpp: In function 'int compute(int, int, int, bool)':
cigle.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int z = 0; z + 1 < tmp[0].size(); z++){
      |                 ~~~~~~^~~~~~~~~~~~~~~
cigle.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int z = 0; z + 1 < tmp[1].size(); z++){
      |                 ~~~~~~^~~~~~~~~~~~~~~
cigle.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int z = 0; z + 1 < tmp[0].size(); z++){
      |                 ~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...