제출 #1121582

#제출 시각아이디문제언어결과실행 시간메모리
1121582vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
361 ms20888 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define in insert #define fi first #define se second #define vl vector<ll> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int sz = 1e6 + 5; /// mind this const int MAX = 2e6 + 123; const int BS = 61; const int mod = 998244353; void solve(){ ll n, k, i, j, ans = 0; cin >> n >> k; vl v(n); for(i = 0; i < n; i++){ cin >> v[i]; } ll m = n / 2; vl S1, S2; for(i = 0; i < (1 << m); i++){ ll s = 0; for(j = 0; j < m; j++){ if(i & (1 << j)){ s += v[j]; } } S1.pb(s); } for(i = 0; i < (1 << (n - m)); i++){ ll s = 0; // cout << i << ": "; for(j = 0; j < (n - m); j++){ if(i & (1 << j)){ // cout << j << ' '; s += v[j + m]; } } // cout << " " << s << endl; S2.pb(s); } sort(all(S1)); sort(all(S2)); // for(auto x: S2){cout << x << ' ';}cout << endl; for(auto x: S1){ if(x > k){break;} ll ix = upper_bound(all(S2), k - x) - S2.begin(); // cout << x << ' ' << ix << endl; ans += ix; } cout << ans << endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; // cin >> t; while(t--){ solve(); } } /* */
#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...