Submission #39490

# Submission time Handle Problem Language Result Execution time Memory
39490 2018-01-16T00:44:26 Z funcsr Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
303 ms 26676 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())

int N;
long long M;
long long A[40];
void dfs(int i, long long s, vector<long long> &X, vector<long long> &ret) {
  if (s > M) return;
  if (i == X.size()) {
    ret.pb(s);
    return;
  }
  dfs(i+1, s, X, ret);
  dfs(i+1, s+X[i], X, ret);
}
vector<long long> enumerate(vector<long long> x) {
  vector<long long> ret;
  dfs(0, 0, x, ret);
  sort(all(ret));
  return ret;
}

int main() {
  cin >> N >> M;
  vector<long long> a[2];
  rep(i, N) cin >> A[i], a[i%2].pb(A[i]);
  a[0] = enumerate(a[0]);
  a[1] = enumerate(a[1]);
  //cout<<"{"; for (long long x : a[0])cout<<x<<",";cout<<"}\n";
  //cout<<"{"; for (long long x : a[1])cout<<x<<",";cout<<"}\n";
  long long sum = 0;
  for (long long x : a[0]) {
    sum += upper_bound(all(a[1]), M-x) - a[1].begin();
  }
  cout << sum << "\n";
  return 0;
}

Compilation message

bobek.cpp: In function 'void dfs(int, long long int, std::vector<long long int>&, std::vector<long long int>&)':
bobek.cpp:16:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (i == X.size()) {
         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 4144 KB Output is correct
2 Correct 66 ms 8244 KB Output is correct
3 Correct 296 ms 26676 KB Output is correct
4 Correct 69 ms 8244 KB Output is correct
5 Correct 6 ms 3636 KB Output is correct
6 Correct 6 ms 2868 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 5172 KB Output is correct
2 Correct 26 ms 4144 KB Output is correct
3 Correct 103 ms 14388 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 3 ms 2868 KB Output is correct
6 Correct 9 ms 3636 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 6192 KB Output is correct
2 Correct 99 ms 10288 KB Output is correct
3 Correct 116 ms 10288 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 66 ms 10288 KB Output is correct
6 Correct 259 ms 26676 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 229 ms 18480 KB Output is correct
2 Correct 19 ms 4144 KB Output is correct
3 Correct 6 ms 2868 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 6 ms 2868 KB Output is correct
6 Correct 226 ms 18480 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 4144 KB Output is correct
2 Correct 69 ms 8244 KB Output is correct
3 Correct 6 ms 2868 KB Output is correct
4 Correct 6 ms 2868 KB Output is correct
5 Correct 59 ms 10288 KB Output is correct
6 Correct 23 ms 4144 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 283 ms 26676 KB Output is correct
2 Correct 23 ms 4144 KB Output is correct
3 Correct 6 ms 2868 KB Output is correct
4 Correct 303 ms 26676 KB Output is correct
5 Correct 73 ms 14388 KB Output is correct
6 Correct 13 ms 3636 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct