Submission #967715

#TimeUsernameProblemLanguageResultExecution timeMemory
967715njoopIce Hockey World Championship (CEOI15_bobek)C++14
0 / 100
115 ms26032 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; ll n, m, arr[50], res1[1100010], res2[1100010], ans, ix; vector<ll> dp1, dp2; void find(int idx, ll mon, int cur, int lim, ll res[]) { if(cur > lim) return; if(mon + arr[cur] <= m) find(idx+pow(2, lim-cur), mon+arr[cur], cur+1, lim, res); find(idx, mon, cur+1, lim, res); if(cur == lim) res[idx] = mon; } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i=1; i<=n; i++) { cin >> arr[i]; } for(int i=0; i<1100010; i++) { res1[i] = -1; res2[i] = -1; } find(0, 0, 1, n/2, res1); find(0, 0, (n/2)+1, n, res2); for(int i=0; i<1100010; i++) { if(res1[i] != -1) dp1.push_back(res1[i]); if(res2[i] != -1) dp2.push_back(res2[i]); } sort(dp2.begin(), dp2.end()); for(int i=0; i<dp1.size(); i++) { ix = lower_bound(dp2.begin(), dp2.end(), m-dp1[i]+1) - dp2.begin(); ans += ix; } cout << ans; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=0; i<dp1.size(); i++) {
      |                  ~^~~~~~~~~~~
#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...