Submission #148083

#TimeUsernameProblemLanguageResultExecution timeMemory
148083WhipppedCreamIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
547 ms8784 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; int n; ll S; const int maxn = 45; ll arr[maxn]; vector< ll > half; ll ways; int main() { scanf("%d %lld", &n, &S); for(int i = 1; i<= n; i++) scanf("%lld", &arr[i]); int m = n/2; for(int bit = 0; bit< (1<<m); bit++) { ll loc = 0; for(int i = 0; i< m; i++) { if((1<<i) & bit) loc += arr[i+1]; } half.pb(loc); } sort(half.begin(), half.end()); m = n-n/2; for(int bit = 0; bit< (1<<m); bit++) { ll loc = 0; for(int i = 0; i< m; i++) { if((1<<i)&bit) loc += arr[n/2+1+i]; } ways += upper_bound(half.begin(), half.end(), S-loc)-half.begin(); } printf("%lld\n", ways); }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %lld", &n, &S);
  ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:24:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= n; i++) scanf("%lld", &arr[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...