Submission #436340

#TimeUsernameProblemLanguageResultExecution timeMemory
436340iulia13Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
351 ms16836 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 6; #define ll long long map <ll, ll> cate; map <ll, ll> dp; set <ll> s; ll v[N]; ll a[N], b[N]; int main() { ll n, m, nr, i, h, j, na, nb; cin >> n >> m; for (i = 0; i < n; i++) cin >> v[i]; h = n / 2; for (i = 0; i < (1 << h); i++) { for (j = 0; j < h; j++) if (i & (1 << j)) a[i] += v[j]; } na = (1 << h); sort(a, a + na); for (i = h; i < n; i++) v[i - h] = v[i]; h = n - h; for (i = 0; i < (1 << h); i++) { for (j = 0; j < h; j++) if (i & (1 << j)) b[i] += v[j]; } nb = (1 << h); sort(b, b + nb); na--; nb--; j = nb; ll ans = 0; for (i = 0; i <= na; i++) { while (b[j] + a[i] > m && j > -1) j--; ans += (j + 1); } cout << ans; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:14:14: warning: unused variable 'nr' [-Wunused-variable]
   14 |     ll n, m, nr, i, h, j, na, nb;
      |              ^~
#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...