답안 #1085767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085767 2024-09-08T16:19:29 Z juicy Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
303 ms 20916 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
 
  int n; long long k; cin >> n >> k;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> lt, rt;
  for (int m = 0; m < (1 << n / 2); ++m) {
    long long sum = 0;
    for (int i = 0; i < n / 2; ++i) {
      if (m >> i & 1) {
        sum += a[i];
      }
    }
    lt.push_back(sum);
  }
  for (int m = 0; m < (1 << n - n / 2); ++m) {
    long long sum = 0;
    for (int i = 0; i < n - n / 2; ++i) {
      if (m >> i & 1) {
        sum += a[n / 2 + i];
      }
    }
    rt.push_back(sum);
  }
  sort(lt.rbegin(), lt.rend());
  sort(rt.begin(), rt.end());
  int j = 0;
  long long res = 0;
  for (auto x : lt) {
    while (j < rt.size() && rt[j] + x <= k) {
      ++j;
    }
    res += j;
  }
  cout << res;
  return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:29:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   29 |   for (int m = 0; m < (1 << n - n / 2); ++m) {
      |                             ~~^~~~~~~
bobek.cpp:43:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     while (j < rt.size() && rt[j] + x <= k) {
      |            ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 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 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 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
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2080 KB Output is correct
2 Correct 73 ms 5584 KB Output is correct
3 Correct 303 ms 20912 KB Output is correct
4 Correct 67 ms 5588 KB Output is correct
5 Correct 12 ms 1752 KB Output is correct
6 Correct 8 ms 1116 KB Output is correct
7 Correct 18 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 3028 KB Output is correct
2 Correct 24 ms 2144 KB Output is correct
3 Correct 120 ms 10492 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 1116 KB Output is correct
6 Correct 16 ms 1756 KB Output is correct
7 Correct 16 ms 1756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 3660 KB Output is correct
2 Correct 101 ms 6720 KB Output is correct
3 Correct 102 ms 6732 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 71 ms 6736 KB Output is correct
6 Correct 247 ms 20808 KB Output is correct
7 Correct 105 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 217 ms 12868 KB Output is correct
2 Correct 24 ms 2144 KB Output is correct
3 Correct 9 ms 1116 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 1112 KB Output is correct
6 Correct 208 ms 12868 KB Output is correct
7 Correct 16 ms 1496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2144 KB Output is correct
2 Correct 71 ms 5536 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 8 ms 1116 KB Output is correct
5 Correct 76 ms 6552 KB Output is correct
6 Correct 23 ms 2144 KB Output is correct
7 Correct 276 ms 20724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 285 ms 20740 KB Output is correct
2 Correct 24 ms 2144 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 287 ms 20916 KB Output is correct
5 Correct 104 ms 10684 KB Output is correct
6 Correct 16 ms 1496 KB Output is correct
7 Correct 32 ms 3032 KB Output is correct