Submission #462012

#TimeUsernameProblemLanguageResultExecution timeMemory
462012kingfran1907Ice Hockey World Championship (CEOI15_bobek)C++14
10 / 100
484 ms8636 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long llint; const int maxn = 2e5+10; const int base = 31337; const int mod = 1e9+7; const int inf = 0x3f3f3f3f; const int logo = 18; const int off = 1 << logo; const int treesiz = off << 1; int n; llint m; llint niz[maxn]; vector< llint > v; int main() { scanf("%d%lld", &n, &m); for (int i = 0; i < n; i++) scanf("%lld", niz+i); int hf = n / 2; int lim = (1 << hf); for (int mask = 0; mask < lim; mask++) { llint sum = 0; for (int i = 0; i < hf; i++) if (mask & (1 << i)) sum += niz[i]; v.push_back(sum); } sort(v.begin(), v.end()); llint sol = 0; lim = (1 << (n - hf)); for (int mask = 0; mask < lim; mask++) { llint sum = 0; for (int i = 0; i < n - hf; i++) { if (mask & (1 << i)) sum += niz[i]; } int ind = upper_bound(v.begin(), v.end(), m - sum) - v.begin(); sol += ind; } printf("%lld\n", sol); return 0; }

Compilation message (stderr)

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