Submission #208565

#TimeUsernameProblemLanguageResultExecution timeMemory
208565fr_klrIce Hockey World Championship (CEOI15_bobek)C++14
30 / 100
229 ms20816 KiB
//You can't fill the hole inside you with money, drugs and cars #include<bits/stdc++.h> using namespace std; long long n, m; vector<long long> v, a, b; void create(long long st, long long en, vector<long long> &w){ long long sz = en - st; w.push_back(0); for(long long mask = 1; mask < (1 << sz); mask++) w.push_back(w[mask - (mask & -mask)] + v[st + __builtin_ctz(mask)]); } long long inp(){ long long A; cin >> A; return A; } void input(){ cin >> n >> m; for(long long i = 0; i < n; i++) v.push_back(inp()); } long long matches(long long p1 = 0, long long p2 = b.size() - 1, long long ans = 0){ sort(a.begin(), a.end()); sort(b.begin(), b.end()); for(; p2 > 0 and p1 < a.size(); p1++){ while(p2 >= 0 and a[p1] + b[p2] > m) p2--; ans += (p2 + 1); } return ans; } long long solve(){ create(0, n/2, a); create(n/2, n, b); return matches(); } int main(){ input(); cout << solve(); }

Compilation message (stderr)

bobek.cpp: In function 'long long int matches(long long int, long long int, long long int)':
bobek.cpp:32:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(; p2 > 0 and p1 < a.size(); p1++){
                      ~~~^~~~~~~~~~
#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...