Submission #699887

#TimeUsernameProblemLanguageResultExecution timeMemory
69988779brueTortoise (CEOI21_tortoise)C++17
48 / 100
398 ms430816 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; int arr[302], sum[302]; int DP[603][302][302][2]; /// 현재 시간, 현재 위치, 산 개수, 손에 든 개수 -> 마지막으로 산 위치 int ans; int main(){ scanf("%d", &n); for(int i=1; i<=n; i++){ scanf("%d", &arr[i]); sum[i] = sum[i-1]; if(arr[i] > 0) sum[i] += arr[i]; } for(int i=0; i<=n+n+1; i++) for(int j=0; j<=n; j++) for(int k=0; k<=n; k++) DP[i][j][k][0] = DP[i][j][k][1] = 1e9; DP[0][1][0][0] = 0; for(int t=0; t<=n+n+1; t++){ for(int i=1; i<=n; i++){ for(int j=0; j<=n; j++){ /// 답 갱신 for(int c=0; c<2; c++) if(DP[t][i][j][c] < 1e9) ans = max(ans, j); /// 시간이 지나지 않는 활동 if(arr[i] == -1){ /// 산 거 넣기 DP[t][i][j][0] = min(DP[t][i][j][0], DP[t][i][j][1]); } if(arr[i] > 0 && DP[t][i][j][0] < sum[i] && i+i-2 >= t){ /// 사기 DP[t][i][j+1][1] = min(DP[t][i][j+1][1], max(DP[t][i][j][0], sum[i-1])+1); } /// 이동하기 for(int c=0; c<2; c++){ DP[t+1][i-1][j][c] = min(DP[t+1][i-1][j][c], DP[t][i][j][c]); DP[t+1][i+1][j][c] = min(DP[t+1][i+1][j][c], DP[t][i][j][c]); // printf("%d %d %d %d: %d\n", t, i, j, c, DP[t][i][j][c]); } } } } printf("%d", sum[n] - ans); }

Compilation message (stderr)

tortoise.cpp: In function 'int main()':
tortoise.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
tortoise.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d", &arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
#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...