Submission #1121828

#TimeUsernameProblemLanguageResultExecution timeMemory
1121828vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
433 ms20908 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; int ans = upper_bound(q.begin(), q.end(), chk) - q.begin(); cnt += (ans); } 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++)
      |                    ~~^~~~~~~~~~
bobek.cpp:48:13: warning: unused variable 'l' [-Wunused-variable]
   48 |         int l = 0, r = q.size() - 1;
      |             ^
bobek.cpp:48:20: warning: unused variable 'r' [-Wunused-variable]
   48 |         int l = 0, r = q.size() - 1;
      |                    ^
#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...