Submission #308918

#TimeUsernameProblemLanguageResultExecution timeMemory
308918syyIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
600 ms8840 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++) #define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--) typedef pair<ll, ll> pi; typedef pair<ll, pi> pii; typedef pair<pi, pi> pipi; #define f first #define s second typedef vector<ll> vi; typedef vector<pi> vpi; typedef vector<pii> vpii; #define pb push_back #define pf push_front #define all(v) v.begin(), v.end() #define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin()); #define INF (ll) 1e9 + 100 #define LLINF (ll) 1e18 #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //can be used by calling rng() or shuffle(A, A+n, rng) inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss ll n, m, arr[45], h, ans; vi v; int main() { fastio; cin >> n >> m; FOR(i, 0, n-1) cin >> arr[i]; h = n/2-1; // [0, h], [h+1, n-1] FOR(i, 0, (1<<(n-1-h-1+1))-1) { ll cur = 0; FOR(j, 0, n-1-h-1) if (i & (1<<j)) cur += arr[j + h+1]; v.pb(cur); } sort(all(v)); FOR(i, 0, (1<<(h+1))-1) { ll cur = 0; FOR(j, 0, h) if (i & (1<<j)) cur += arr[j]; auto it = upper_bound(all(v), m-cur); ans += it - v.begin(); } cout << ans; }
#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...