Submission #1121788

#TimeUsernameProblemLanguageResultExecution timeMemory
1121788vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
10 / 100
348 ms20800 KiB
#include <bits/stdc++.h> using namespace std; # define int long long const int maxn = 1e6 + 5; void solve() { int n, k, cnt = 0; cin >> n >> k; vector < int > a(n); vector < int > pr1; vector < int > pr2; vector < int > p; vector < int > q; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n / 2 + (n % 2); i++) pr1.push_back(a[i]); for(int i = n / 2 + (n % 2); i < n; i++) pr2.push_back(a[i]); for(int i = 0; i < pow(2, pr1.size()); i++) { int ans = 0; for(int j = 0; j < pr1.size(); j++) { if(i & (1 << j)) { ans += pr1[j]; } } p.push_back(ans); } for(int i = 0; i < pow(2, pr2.size()); i++) { int ans = 0; for(int j = 0; j < pr2.size(); j++) { if(i & (1 << j)) ans += pr2[j]; } q.push_back(ans); } sort(q.begin(), q.end()); for(int i = 0; i < p.size(); i++) { int chk = k - p[i]; int l = 0, r = q.size() - 1; if(q[0] > chk) continue; while(r > l) { int mid = (l + r) / 2; if(q[mid] >= chk) r = mid - 1; else l = mid + 1; } cnt += (l + 1); } cout << cnt << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tt = 1; // cin >> tt; while(tt--) solve(); }

Compilation message (stderr)

bobek.cpp: In function 'void solve()':
bobek.cpp:24:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j = 0; j < pr1.size(); j++)
      |                        ~~^~~~~~~~~~~~
bobek.cpp:37:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int j = 0; j < pr2.size(); j++)
      |                        ~~^~~~~~~~~~~~
bobek.cpp:45:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0; i < p.size(); 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...