Submission #461162

#TimeUsernameProblemLanguageResultExecution timeMemory
461162vanicIce Hockey World Championship (CEOI15_bobek)C++14
70 / 100
1096 ms7424 KiB
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> using namespace std; typedef long long ll; const int maxn=45; ll a[maxn]; ll pref[maxn]; ll sol; void rijesi(int x, ll sum){ if(sum<0){ return; } if(sum>=pref[x+1]){ sol+=(1ll<<(x+1)); return; } sol++; for(int i=x; i>-1; i--){ rijesi(i-1, sum-a[i]); } } const int maxm=1e6+5; ll dp[maxm]; int n; ll m; void rokaj(){ dp[0]=1; for(int i=0; i<n; i++){ for(int j=m; j>=a[i]; j--){ dp[j]+=dp[j-a[i]]; } } for(int i=0; i<=m; i++){ sol+=dp[i]; } } int main(){ scanf("%d%lld", &n, &m); for(int i=0; i<n; i++){ scanf("%lld", a+i); } sort(a, a+n); for(int i=0; i<n; i++){ pref[i+1]=pref[i]+a[i]; } if(m<=1e6){ rokaj(); } else{ rijesi(n-1, m); } printf("%lld\n", sol); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |  scanf("%d%lld", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
bobek.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   scanf("%lld", a+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...