Submission #461293

#TimeUsernameProblemLanguageResultExecution timeMemory
461293vanicIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
247 ms20900 KiB
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> using namespace std; typedef long long ll; const int maxn=45; vector < ll > v[2]; int n; ll m; ll a[maxn]; ll pref[maxn]; ll sol; int gran, ind; void rijesi(int x, ll sum){ // cout << x << endl; if(x==gran){ v[ind].push_back(sum); return; } rijesi(x+1, sum+a[x]); rijesi(x+1, sum); } int main(){ scanf("%d%lld", &n, &m); for(int i=0; i<n; i++){ scanf("%lld", a+i); pref[i+1]=pref[i]+a[i]; } gran=n/2; ind=0; rijesi(0, 0); gran=n; ind=1; rijesi(n/2, 0); sort(v[0].begin(), v[0].end()); sort(v[1].begin(), v[1].end()); int pos=0; for(int i=v[0].size()-1; i>=0; i--){ while(pos<(int)v[1].size() && v[1][pos]<=m-v[0][i]){ pos++; } sol+=pos; } printf("%lld\n", sol); return 0; }

Compilation message (stderr)

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