Submission #95748

#TimeUsernameProblemLanguageResultExecution timeMemory
95748popovicirobertIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
345 ms20984 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long #define ld long double // 217 // 44 using namespace std; const int MAXN = 40; ll a[MAXN], b[MAXN]; int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); int i, n; ll m; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> m; int sz1 = (n + 1) / 2, sz2 = n / 2; for(i = 0; i < sz1; i++) { cin >> a[i]; } vector <ll> sa; for(int conf = 0; conf < (1 << sz1); conf++) { ll cur = 0; for(i = 0; i < sz1; i++) { if(conf & (1 << i)) { cur += a[i]; } } sa.push_back(cur); } sort(sa.begin(), sa.end()); for(i = 0; i < sz2; i++) { cin >> b[i]; } vector <ll> sb; for(int conf = 0; conf < (1 << sz2); conf++) { ll cur = 0; for(i = 0; i < sz2; i++) { if(conf & (1 << i)) { cur += b[i]; } } sb.push_back(cur); } sort(sb.begin(), sb.end()); int pos = (1 << sz2) - 1; ll ans = 0; for(i = 0; i < (1 << sz1); i++) { while(pos >= 0 && sa[i] + sb[pos] > m) { pos--; } ans += pos + 1; } cout << ans; //cin.close(); //cout.close(); return 0; }
#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...