제출 #1254382

#제출 시각아이디문제언어결과실행 시간메모리
1254382nvc2k8Ice Hockey World Championship (CEOI15_bobek)C++20
100 / 100
390 ms8644 KiB
#include <bits/stdc++.h> #define TASK "aksjdkasjd" #define endl '\n' #define mp make_pair #define pb push_back #define fi first #define se second #define BIT(i,x) (((i)>>(x))&1) #define FOR(i,a,b) for(int i = (a); i<=(b); i++) #define FORD(i,a,b) for(int i = (a); i>=(b); i--) #define all(C) C.begin(), C.end() using namespace std; using ll = long long; using pii = pair<int,int>; const int INT_LIM = 2147483647; const ll LL_LIM = 9223372036854775807; template <typename X> bool minimize(X &x, const X &y) {if (x>y){x = y; return true;}return false;} template <typename X> bool maximize(X &x, const X &y) {if (x<y){x = y; return true;}return false;} ///------------------------------------------/// int n; ll m; ll a[45]; void inp() { cin >> n >> m; FOR(i, 1, n) cin >> a[i]; } int c; ll f[1<<20]; int findl(ll x) { int l = 0, r = (1<<c)-1, ret = -1; while(l<=r) { int mid = (l+r)>>1; if (f[mid]<=x) { ret = mid; l = mid+1; } else r = mid-1; } return ret+1; } ll ans = 0; void solve() { c = (n+1)/2; FOR(mask, 0, (1<<c)-1) { FOR(i, 1, c) if (BIT(mask, i-1)) f[mask]+= a[i]; } sort(f, f+(1<<c)); FOR(mask, 0, (1<<(n-c))-1) { ll sum = 0; FOR(i, c+1, n) if (BIT(mask, i-(c+1))) sum+= a[i]; if (sum<=m) { ans+= findl(m-sum); } } cout << ans << endl; } signed main() { ///--------------------------/// ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen(TASK".INP","r")!=NULL) { freopen(TASK".INP","r",stdin); freopen(TASK".OUT","w",stdout); } ///--------------------------/// int NTEST = 1; bool codeforces = 0; if (codeforces) cin >> NTEST; while (NTEST--) { inp(); solve(); } return 0; } ///------------------------------------------///

컴파일 시 표준 에러 (stderr) 메시지

bobek.cpp: In function 'int main()':
bobek.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen(TASK".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bobek.cpp:80:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         freopen(TASK".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...