Submission #106167

#TimeUsernameProblemLanguageResultExecution timeMemory
106167xiaowuc1Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
369 ms20952 KiB
#include <algorithm> #include <cassert> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, int> plli; typedef vector<vector<ll>> matrix; void gen(vector<ll>& init, vector<ll>& ret) { for(int mask = 0; mask < 1 << init.size(); mask++) { ll curr = 0; for(int i = 0; i < init.size(); i++) { if(mask&(1LL<<i)) curr += init[i]; } ret.push_back(curr); } sort(ret.begin(), ret.end()); } void solve() { int n; ll thresh; cin >> n >> thresh; vector<ll> a, b; for(int i = 0; i < n; i++) { ll t; cin >> t; (i%2?a:b).push_back(t); } vector<ll> ar, br; gen(a, ar); gen(b, br); ll ret = 0; int j = br.size()-1; for(int i = 0; i < ar.size() && j >= 0; i++) { while(j >= 0 && ar[i] + br[j] > thresh) j--; ret += j+1; } cout << ret << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /* int t; cin >> t; for(int i = 1; i <= t; i++) { cout << "Case #" << i << ": "; solve(); } */ solve(); }

Compilation message (stderr)

bobek.cpp: In function 'void gen(std::vector<long long int>&, std::vector<long long int>&)':
bobek.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < init.size(); i++) {
                    ~~^~~~~~~~~~~~~
bobek.cpp: In function 'void solve()':
bobek.cpp:45:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < ar.size() && j >= 0; 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...