Submission #524901

#TimeUsernameProblemLanguageResultExecution timeMemory
524901fuad27Ice Hockey World Championship (CEOI15_bobek)C++17
0 / 100
367 ms8720 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; // using namespace chrono; // using namespace atcoder; // template <typename T> // using ordered_set = // tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; typedef long long ll; typedef long double ld; const ll INF = 1e18; #define pii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vll vector<ll> #define rep(i, a, b) for(int i = a;i<b;i++) #define ss second #define ff first template<typename T> auto operator<<(ostream &os, T&v)->decltype(v.begin(), os){ os << "["; int f = 0; for(auto i:v) { if(f++)os << ", "; os << i; } os << "]"; return os; } template<typename F, typename S> auto& operator<<(ostream &os, pair<F, S> const &p) { return os << "(" << p.first << ", " << p.second << ")"; } void debug(){} template<typename T, typename... V> void debug(T t, V... v) { cerr << t; if(sizeof...(v)) { cerr << ", "; debug(v...); } } #ifdef LOCAL #define dbg(x...) cerr << "[" << #x << "]: " << "["; debug(x); cerr << "]\n"; #define nl cerr << "\n"; #else #define dbg(x...) #define nl #endif vector<vector<long long> > g(80, vector<long long> (80, 0)); long long dp[80][80]; void solve() { int n; long long k; cin >> n >> k; long long sz1 = (n+1)>>1, sz2 = n - ((n+1)>>1); long long a[sz1], b[sz2]; for(int i=0;i<n;i++) { if(i < sz1)cin >> a[i]; else cin >> b[i-sz1]; } vector<long long> suma; for(long long i = 0;i<(1ll<<sz1);i++) { long long s = 0; for(int j = 0;j<sz1;j++) { if(i&(1ll<<j))s += a[j]; } suma.push_back(s); } long long ans = 0; sort(suma.begin(), suma.end()); dbg(suma); for(long long i = 0;i<(1ll<<sz2);i++) { long long s = 0; for(int j = 0;j<sz1;j++) { if(i&(1ll<<j))s += b[j]; } dbg(s, k-s); ans += (--upper_bound(suma.begin(), suma.end(), k-s)) - suma.begin(); } cout << ans << endl; } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while(t--) { solve(); } 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...