Submission #972727

#TimeUsernameProblemLanguageResultExecution timeMemory
972727blackslexIce Hockey World Championship (CEOI15_bobek)C++17
10 / 100
331 ms21760 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int n; ll m; int main() { scanf("%d %lld", &n, &m); vector<ll> a(n); for (auto &e: a) scanf("%lld", &e); auto get = [&] (int l, int r) { vector<ll> c; int sz = r - l + 1; for (int i = 0; i < (1 << sz); i++) { ll csum = 0; for (int j = 0; j < sz; j++) { if (i & (1 << j)) csum += a[j + l]; } if (csum <= m) c.emplace_back(csum); } sort(c.begin(), c.end()); return c; }; int posl = 0, posr = n / 2; auto cl = get(posl, posr - 1), cr = get(posr, n - 1); ll ans = cl.size() + cr.size() - 1; for (auto &e: cl) { if (!e) continue; auto lower = lower_bound(cr.begin(), cr.end(), m - e); if (*lower > m - e && lower != cr.begin()) lower = prev(lower); ans += (lower - cr.begin()); } printf("%lld", ans); }

Compilation message (stderr)

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