Submission #65778

# Submission time Handle Problem Language Result Execution time Memory
65778 2018-08-08T18:00:52 Z Googal Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
303 ms 21496 KB
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const int NMAX = 50;

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) {
                  ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
3 Correct 2 ms 720 KB Output is correct
4 Correct 4 ms 720 KB Output is correct
5 Correct 3 ms 720 KB Output is correct
6 Correct 2 ms 828 KB Output is correct
7 Correct 2 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 828 KB Output is correct
2 Correct 3 ms 828 KB Output is correct
3 Correct 2 ms 828 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 2 ms 828 KB Output is correct
6 Correct 3 ms 828 KB Output is correct
7 Correct 2 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 828 KB Output is correct
2 Correct 3 ms 924 KB Output is correct
3 Correct 2 ms 924 KB Output is correct
4 Correct 2 ms 924 KB Output is correct
5 Correct 4 ms 924 KB Output is correct
6 Correct 3 ms 924 KB Output is correct
7 Correct 2 ms 924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2472 KB Output is correct
2 Correct 68 ms 5932 KB Output is correct
3 Correct 277 ms 21348 KB Output is correct
4 Correct 70 ms 21348 KB Output is correct
5 Correct 11 ms 21348 KB Output is correct
6 Correct 9 ms 21348 KB Output is correct
7 Correct 15 ms 21348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 21348 KB Output is correct
2 Correct 24 ms 21348 KB Output is correct
3 Correct 97 ms 21348 KB Output is correct
4 Correct 2 ms 21348 KB Output is correct
5 Correct 6 ms 21348 KB Output is correct
6 Correct 15 ms 21348 KB Output is correct
7 Correct 15 ms 21348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 21348 KB Output is correct
2 Correct 90 ms 21348 KB Output is correct
3 Correct 94 ms 21348 KB Output is correct
4 Correct 3 ms 21348 KB Output is correct
5 Correct 52 ms 21348 KB Output is correct
6 Correct 207 ms 21348 KB Output is correct
7 Correct 92 ms 21348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 21348 KB Output is correct
2 Correct 25 ms 21348 KB Output is correct
3 Correct 11 ms 21348 KB Output is correct
4 Correct 3 ms 21348 KB Output is correct
5 Correct 7 ms 21348 KB Output is correct
6 Correct 192 ms 21348 KB Output is correct
7 Correct 18 ms 21348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 21348 KB Output is correct
2 Correct 59 ms 21348 KB Output is correct
3 Correct 9 ms 21348 KB Output is correct
4 Correct 9 ms 21348 KB Output is correct
5 Correct 52 ms 21348 KB Output is correct
6 Correct 22 ms 21348 KB Output is correct
7 Correct 303 ms 21452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 251 ms 21452 KB Output is correct
2 Correct 26 ms 21452 KB Output is correct
3 Correct 11 ms 21452 KB Output is correct
4 Correct 285 ms 21496 KB Output is correct
5 Correct 64 ms 21496 KB Output is correct
6 Correct 16 ms 21496 KB Output is correct
7 Correct 35 ms 21496 KB Output is correct