Submission #24702

#TimeUsernameProblemLanguageResultExecution timeMemory
24702kdh9949Ice Hockey World Championship (CEOI15_bobek)C++14
90 / 100
366 ms18404 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, p, q; ll m, x[20], y[20], a[1048576], b[1048576], ans; int main(){ scanf("%d%lld", &n, &m); p = n / 2; q = n - p; if(n == 1){ ll x; scanf("%lld", &x); printf("%lld\n", x <= m ? x : 0); return 0; } for(int i = 0; i < p; i++){ scanf("%lld", x + i); } for(int i = 0; i < q; i++){ scanf("%lld", y + i); } for(int i = 0; i < (1 << p); i++){ for(int j = 0; j < p; j++) if((1 << j) & i) a[i] += x[j]; } for(int i = 0; i < (1 << q); i++){ for(int j = 0; j < q; j++) if((1 << j) & i) b[i] += y[j]; } sort(a, a + (1 << p)); sort(b, b + (1 << q)); for(int i = 0, j = (1 << q) - 1; i < (1 << p); i++){ for(; j >= 0; j--){ if(a[i] + b[j] <= m) break; } ans += (j + 1); } printf("%lld\n", ans); }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:9:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld", &n, &m);
                         ^
bobek.cpp:12:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ll x; scanf("%lld", &x);
                          ^
bobek.cpp:17:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", x + i);
                       ^
bobek.cpp:20:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", y + i);
                       ^
#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...