Submission #935090

# Submission time Handle Problem Language Result Execution time Memory
935090 2024-02-28T15:23:46 Z ind1v Ice Hockey World Championship (CEOI15_bobek) C++11
100 / 100
417 ms 10548 KB
#include <bits/stdc++.h>

using namespace std;

int n;
long long m;
vector<long long> c;
vector<long long> a, b;
vector<long long> c1;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  c.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n / 2; i++) {
    a.emplace_back(c.back());
    c.pop_back();
  }
  while (!c.empty()) {
    b.emplace_back(c.back());
    c.pop_back();
  }
  for (int msk = 0; msk < (1 << a.size()); msk++) {
    long long s = 0;
    for (int i = 0; i < a.size(); i++) {
      if (msk >> i & 1) {
        s += a[i];
      }
    }
    c1.emplace_back(s);
  }
  sort(c1.begin(), c1.end());
  long long ans = 0;
  for (int msk = 0; msk < (1 << b.size()); msk++) {
    long long s = 0;
    for (int i = 0; i < b.size(); i++) {
      if (msk >> i & 1) {
        s += b[i];
      }
    }
    ans += (upper_bound(c1.begin(), c1.end(), m - s) - c1.begin());
  }
  cout << ans << '\n';
  return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
bobek.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < b.size(); i++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 420 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 992 KB Output is correct
2 Correct 85 ms 2520 KB Output is correct
3 Correct 391 ms 10016 KB Output is correct
4 Correct 79 ms 2516 KB Output is correct
5 Correct 12 ms 992 KB Output is correct
6 Correct 6 ms 736 KB Output is correct
7 Correct 11 ms 992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1500 KB Output is correct
2 Correct 25 ms 988 KB Output is correct
3 Correct 171 ms 6096 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 11 ms 988 KB Output is correct
7 Correct 11 ms 988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 1500 KB Output is correct
2 Correct 132 ms 2520 KB Output is correct
3 Correct 130 ms 2520 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 56 ms 2516 KB Output is correct
6 Correct 203 ms 10548 KB Output is correct
7 Correct 64 ms 2516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 289 ms 6612 KB Output is correct
2 Correct 24 ms 992 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 736 KB Output is correct
6 Correct 137 ms 4672 KB Output is correct
7 Correct 11 ms 992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1064 KB Output is correct
2 Correct 81 ms 2516 KB Output is correct
3 Correct 9 ms 732 KB Output is correct
4 Correct 8 ms 736 KB Output is correct
5 Correct 78 ms 2520 KB Output is correct
6 Correct 15 ms 992 KB Output is correct
7 Correct 206 ms 9432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 326 ms 10192 KB Output is correct
2 Correct 27 ms 988 KB Output is correct
3 Correct 8 ms 736 KB Output is correct
4 Correct 417 ms 9876 KB Output is correct
5 Correct 90 ms 6612 KB Output is correct
6 Correct 11 ms 992 KB Output is correct
7 Correct 23 ms 1500 KB Output is correct