Submission #588637

#TimeUsernameProblemLanguageResultExecution timeMemory
588637peuchUplifting Excursion (BOI22_vault)C++17
0 / 100
0 ms212 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 610; const long long INF = 1e18; int m; long long l; long long aux[MAXN]; long long *v = aux + 300; int main(){ scanf("%d %lld", &m, &l); for(int i = -m; i <= m; i++) scanf("%lld", &v[i]); long long sum = 0; long long cnt = 0; for(int i = 1; i <= m; i++){ if(sum + v[i] * i <= l){ sum += v[i] * i; cnt += v[i]; continue; } cnt += ((l - sum) / i + 1); sum += i * ((l - sum) / i + 1); } if(sum < l){ printf("impossible\n"); return 0; } vector<long long> dp(sum - l + 1, INF); dp[0] = 0; vector<int> moedas; for(int i = 1; i <= m; i++){ for(int j = 0; j < min(300LL, v[i]); j++) moedas.push_back(i); } for(int i = 0; i < moedas.size(); i++){ for(int j = moedas[i]; j < dp.size(); j++){ dp[j] = min(dp[j], dp[j - moedas[i]] + 1); } } if(dp.back() == INF) printf("impossible\n"); else printf("%lld\n", v[0] + cnt - dp.back()); }

Compilation message (stderr)

vault.cpp: In function 'int main()':
vault.cpp:42:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i = 0; i < moedas.size(); i++){
      |                 ~~^~~~~~~~~~~~~~~
vault.cpp:43:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int j = moedas[i]; j < dp.size(); j++){
      |                          ~~^~~~~~~~~~~
vault.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d %lld", &m, &l);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
vault.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%lld", &v[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...