Submission #28747

#TimeUsernameProblemLanguageResultExecution timeMemory
28747rondojimIce Hockey World Championship (CEOI15_bobek)C++14
0 / 100
486 ms13548 KiB
#include <stdio.h> #include <vector> #include <algorithm> using namespace std; const int MAXN = 40; typedef long long ll; ll N, K, A[MAXN], result; int main(){ #ifdef DEBUG freopen("input.txt", "r", stdin); #endif scanf("%lld %lld", &N, &K); for(int i=0; i<N; ++i) scanf("%lld", &A[i]); int middle = N / 2, remain = N - N / 2; vector<ll> sums; for(int bitm=0; bitm<(1<<middle); ++bitm){ ll sum = 0; for(int i=0; i<middle; ++i) if(bitm & (1<<i)) sum += A[i]; sums.push_back(sum); } sort(sums.begin(), sums.end()); for(int bitm=0; bitm<(1<<remain); ++bitm){ ll sum = 0; for(int i=0; i<remain; ++i) if(bitm & (1<<i)) sum += A[middle + i]; int lo = 0, hi = sums.size() - 1, res = -1, mid; while(lo <= hi){ mid = (lo + hi)>>1; if(sums[mid] + sum < K) lo = mid + 1; else res = mid, hi = mid - 1; } if(res != -1) result += sums.size() - res; } printf("%lld\n", result); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:17:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &N, &K);
                             ^
bobek.cpp:18:46: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for(int i=0; i<N; ++i) scanf("%lld", &A[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...