Submission #1241205

#TimeUsernameProblemLanguageResultExecution timeMemory
1241205_dtq_Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
409 ms8624 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define sz(x) (ll)(x.size()) #define all(v) v.begin(), v.end() #define sz(x) (ll)(x.size()) #define se second #define fi first using namespace std; const ll N = 50; ll n, i, k, a[N]; int main() { #define TN "" if (fopen(TN ".inp", "r")) { freopen(TN ".inp", "r", stdin); freopen(TN ".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> n >> k; for( i = 1; i <= n; i ++ ) cin >> a[i]; ll x = n / 2, y = n - x; vector<ll>vec; for( i = 0; i < (1 << y); i ++ ) { ll sum = 0; for( int w = 0; w < y; w ++ ) if(i & (1 << w)) sum += a[w + 1 + x]; vec.pb(sum); } sort(all(vec)); ll ans = 0; for( i = 0; i < (1 << x); i ++ ) { ll sum = 0; for( int w = 0; w < x; w ++ ) if(i & (1 << w)) sum += a[w + 1]; if(sum > k) continue; ll vt = upper_bound(all(vec), k - sum) - vec.begin() - 1; ans += (vt + 1); } cout << ans; return 0; } /* */

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(TN ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bobek.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(TN ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...