제출 #1121499

#제출 시각아이디문제언어결과실행 시간메모리
1121499OmarAlimammadzadeIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
335 ms20900 KiB
// author - alimammadzade #include <bits/stdc++.h> #define int long long using namespace std; signed main() { cin.tie(nullptr)->sync_with_stdio(false); // system("cls"), freopen("in.txt", "r", stdin); int n, m, res = 0; cin >> n >> m; vector<int> fi, se; vector<int> fii, see; for (int i = 0; i < n / 2; i++) { int x; cin >> x; fi.push_back(x); } for (int i = n / 2; i < n; i++) { int x; cin >> x; se.push_back(x); } int n1 = fi.size(), n2 = se.size(); for (int i = 0; i < (1 << n1); i++) { int sum = 0; for (int j = 0; j < n1; j++) if (i & (1 << j)) sum += fi[j]; fii.push_back(sum); } for (int i = 0; i < (1 << n2); i++) { int sum = 0; for (int j = 0; j < n2; j++) if (i & (1 << j)) sum += se[j]; see.push_back(sum); } sort(fii.begin(), fii.end()); sort(see.begin(), see.end()); for (int& i : fii) { if (i > m) break; res += upper_bound(see.begin(), see.end(), m - i) - see.begin(); } cout << res; }
#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...