답안 #65766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65766 2018-08-08T17:45:46 Z Googal Ice Hockey World Championship (CEOI15_bobek) C++14
40 / 100
1000 ms 1049600 KB
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const int NMAX = 25;

int n;
ll v[NMAX];
ll m, res;

vector < ll > a1;
vector < ll > a2;

void solve(int pos, int lim, ll sum, vector < ll > &a) {
  if(pos == lim) {
    a.push_back(sum);
    return;
  }

  solve(pos + 1, lim, sum, a);
  solve(pos + 1, lim, sum + v[pos], a);
}

int main()
{
  ios::sync_with_stdio(false);

  cin >> n >> m;
  for(int i = 0; i < n; i++)
    cin >> v[i];

  solve(0, n / 2, 0, a1);
  sort(a1.begin(), a1.end());

  solve(n / 2, n, 0, a2);
  sort(a2.begin(), a2.end());

  int val = a2.size() - 1;

  for(int i = 0; i < a1.size(); ++i) {
    if(m < a1[i])
      break;
    while(a2[val] > m - a1[i] && 0 <= val)
      val--;

    res += val;
    res++;
  }

  cout << res << '\n';
  return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:44:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < a1.size(); ++i) {
                  ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 496 KB Output is correct
2 Correct 4 ms 652 KB Output is correct
3 Correct 4 ms 652 KB Output is correct
4 Correct 3 ms 652 KB Output is correct
5 Correct 3 ms 652 KB Output is correct
6 Correct 3 ms 652 KB Output is correct
7 Correct 3 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 652 KB Output is correct
2 Correct 3 ms 652 KB Output is correct
3 Correct 3 ms 700 KB Output is correct
4 Correct 4 ms 716 KB Output is correct
5 Correct 4 ms 716 KB Output is correct
6 Correct 3 ms 716 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 720 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 3 ms 792 KB Output is correct
4 Correct 3 ms 792 KB Output is correct
5 Correct 2 ms 792 KB Output is correct
6 Correct 3 ms 796 KB Output is correct
7 Correct 3 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 434496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1118 ms 508768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 508768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1070 ms 508768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1135 ms 1049600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1045 ms 1049600 KB Time limit exceeded
2 Halted 0 ms 0 KB -