Submission #281998

#TimeUsernameProblemLanguageResultExecution timeMemory
281998ChrisTIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
253 ms20944 KiB
#include <bits/stdc++.h> using namespace std; int main () { int n; long long m; scanf ("%d %lld",&n,&m); vector<long long> a(n), sums1, sums2; int ed; for (auto &au : a) scanf ("%lld",&au); function<void(int,long long,vector<long long>&)> gen = [&] (int ind, long long sum, vector<long long> &sums) { if (ind == ed) return (void)sums.push_back(sum); gen(ind+1,sum,sums); gen(ind+1,sum+a[ind],sums); }; ed = n/2; gen(0,0,sums1); ed = n; gen(n/2,0,sums2); sort(sums1.begin(),sums1.end()); sort(sums2.begin(),sums2.end()); long long ret = 0; int pp = (int)sums2.size() - 1; for (int i = 0; i < (int)sums1.size(); i++) { while (~pp && sums1[i] + sums2[pp] > m) --pp; ret += pp + 1; } printf ("%lld\n",ret); return 0; }

Compilation message (stderr)

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