Submission #894619

#TimeUsernameProblemLanguageResultExecution timeMemory
894619IWKRIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
425 ms22716 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { int n, m; cin >> n >> m; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } int a = n / 2; vector<int> v; vector<int> v2; int ans = 0; for (int i = 0; i < (1 << a); i++) { int res = 0; for (int j = 0; j < a; j++) { if (i & (1 << j)) { res += arr[j]; } } if (res <= m) { v.push_back(res); } } int b = n - a; for (int i = 0; i < (1 << b); i++) { int res = 0; for (int j = 0; j < b; j++) { if (i & (1 << j)) { res += arr[a + j]; } } if (res <= m) { v2.push_back(res); } } sort(v.begin(), v.end()); for (int i = 0; i < v2.size(); i++) { int low = 0; int high = v.size(); while (high - low > 1) { int mid = (high + low) / 2; if (v[mid] + v2[i] <= m) { low = mid; } else { high = mid; } } ans += low + 1; } cout << ans; }

Compilation message (stderr)

bobek.cpp: In function 'int32_t main()':
bobek.cpp:41:23: 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]
   41 |     for (int i = 0; i < v2.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...