Submission #39490

#TimeUsernameProblemLanguageResultExecution timeMemory
39490funcsrIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
303 ms26676 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...