Submission #53083

#TimeUsernameProblemLanguageResultExecution timeMemory
53083Alexa2001Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
413 ms21504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int Nmax = 100; ll a[Nmax], b[Nmax], ans = 0, sum, money; vector<ll> A, B; int i, j, n, m; int main() { // freopen("input", "r", stdin); // freopen("output", "w", stdout); cin.sync_with_stdio(false); cin >> n >> money; m = n>>1; n -= m; for(i=0; i<n; ++i) cin >> a[i]; for(i=0; i<m; ++i) cin >> b[i]; for(i=0; i<(1<<n); ++i) { sum = 0; for(j=0; j<n; ++j) if(i & (1<<j)) sum += a[j]; A.push_back(sum); } for(i=0; i<(1<<m); ++i) { sum = 0; for(j=0; j<m; ++j) if(i & (1<<j)) sum += b[j]; B.push_back(sum); } sort(A.begin(), A.end()); reverse(A.begin(), A.end()); sort(B.begin(), B.end()); j = 0; for(i=0; i<A.size(); ++i) { while(j<B.size() && A[i] + B[j] <= money) ++j; ans += j; } cout << ans << '\n'; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:44:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<A.size(); ++i)
              ~^~~~~~~~~
bobek.cpp:46:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(j<B.size() && A[i] + B[j] <= money) ++j;
               ~^~~~~~~~~
#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...