Submission #879433

#TimeUsernameProblemLanguageResultExecution timeMemory
879433KN200711Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
421 ms22192 KiB
# include <bits/stdc++.h> # define ll long long using namespace std; int main() { int N; ll K; scanf("%d %lld", &N, &K); vector<ll> arr(N); for(int i=0;i<N;i++) { scanf("%lld", &arr[i]); } vector<ll> A, B; A.clear(); B.clear(); int G = N / 2; for(int i=0;i<(1 << G);i++) { ll as = 0ll; for(int k=0;k<G;k++) { if(i&(1 << k)) as += arr[k]; } A.push_back(as); } for(int i=0;i<(1 << (N - G));i++) { ll as = 0ll; for(int k=0;k<(N - G);k++) { if(i&(1 << k)) as += arr[k + G]; } B.push_back(as); } sort(B.begin(), B.end()); ll ans = 0ll; for(int i=0;i<A.size();i++) { ans += 1ll * ( upper_bound(B.begin(), B.end(), K - A[i]) - B.begin()); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int i=0;i<A.size();i++) {
      |              ~^~~~~~~~~
bobek.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d %lld", &N, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   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...