Submission #1005104

#TimeUsernameProblemLanguageResultExecution timeMemory
1005104Essa2006Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
316 ms16864 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n; ll m; cin >> n >> m; vector<ll> C(n); for (int i = 0; i < n; i++) { cin >> C[i]; } array<int, 2> sz = {n / 2, (n + 1) / 2}; array<vector<ll>, 2> A; A[0].clear(), A[1].clear(); A[0].reserve(1 << 20), A[1].reserve(1 << 20); for (int j = 0; j < 2; j++) { int shift = (j ? sz[j - 1] : 0); for (int msk = 1; msk < (1 << sz[j]); msk++) { int cur = msk; A[j].push_back(C[__builtin_ctz (msk) + shift]); cur = cur & (cur - 1); while (cur) { A[j].back() += (C[__builtin_ctz(cur) + shift]); cur = cur & (cur - 1); } } } sort(all(A[1])); A[0].push_back(0); ll ans = 0; for (int i = 0; i < A[0].size(); i++) { if (A[0][i] > m) { continue; } ans++; int ind = upper_bound(all(A[1]), m - A[0][i]) - A[1].begin(); ans += ind; } cout << ans; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (int i = 0; i < A[0].size(); 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...