제출 #577768

#제출 시각아이디문제언어결과실행 시간메모리
577768patrikpavic2Uplifting Excursion (BOI22_vault)C++17
0 / 100
0 ms212 KiB
#include <cstdio> #include <algorithm> using namespace std; typedef long long ll; const int M = 32; const int INF = 0x3f3f3f3f; int m; ll L, A[M], kol, B[M]; int dp[M * M]; ll greedy(ll cur){ if(cur < 0) return 0; ll ret = 0; for(int i = 1;i <= m;i++){ ll uz = min(B[i], cur / i); cur -= uz * i; ret += uz; } return cur == 0 ? ret : -1; } int main(){ scanf("%d%lld", &m, &L); for(int i = m;i >= 1;i--){ ll x; scanf("%lld", &x); // A[i] += x; L += x * i; } ll bla; scanf("%lld", &bla); for(int i = 1;i <= m;i++){ ll x; scanf("%lld", &x); A[i] += x; } for(int i = 1;i <= m;i++){ B[i] = A[i] - min(A[i], (ll)M); A[i] -= B[i]; } for(int i = 1;i < M * M + M;i++) dp[i] = -INF; for(int i = 1;i <= m;i++){ for(int j = 0;j < A[i];j++){ for(int k = M * M - 1;k >= i;k--) dp[k] = max(dp[k], 1 + dp[k - i]); } } ll odg = -1; for(int LL = 0;LL < M * M;LL++){ if(dp[LL] < 0) continue; ll jos = greedy(L - LL); if(jos == -1) continue; odg = max(odg, dp[LL] + jos + bla); } if(odg < 0) printf("impossible\n"); else printf("%lld\n", odg); return 0; }

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

vault.cpp: In function 'int main()':
vault.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d%lld", &m, &L);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
vault.cpp:28:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         ll x; scanf("%lld", &x);
      |               ~~~~~^~~~~~~~~~~~
vault.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     ll bla; scanf("%lld", &bla);
      |             ~~~~~^~~~~~~~~~~~~~
vault.cpp:33:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         ll x; scanf("%lld", &x);
      |               ~~~~~^~~~~~~~~~~~
vault.cpp:41:15: warning: iteration 1023 invokes undefined behavior [-Waggressive-loop-optimizations]
   41 |         dp[i] = -INF;
      |         ~~~~~~^~~~~~
vault.cpp:40:21: note: within this loop
   40 |     for(int i = 1;i < M * M + M;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...
#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...