Submission #241669

#TimeUsernameProblemLanguageResultExecution timeMemory
241669anonymousIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
681 ms25156 KiB
#include <iostream> #include <vector> #include <algorithm> #define LL long long using namespace std; LL N, M, Wt[45], Ways; vector <LL> List; vector <pair<LL,int> > Freq2; int main() { //freopen("bobekin.txt","r",stdin); scanf("%lld %lld",&N,&M); for (int i=0; i < N; i++) { scanf("%lld", &Wt[i]); } for (int i=0; i < 1<<(N/2); i++) { LL wt = 0; for (int j=0; j < N/2; j++) { if (i & (1<<j)) {wt += Wt[j];} } if (wt <= M) { List.push_back(wt); } } sort(List.begin(), List.end()); for (int i=0; i<List.size(); i++) { if (i + 1 == List.size() || List[i] != List[i+1]) { Freq2.push_back({List[i], i+1}); } } for (int i=0; i < 1<< (N - N/2); i++) { LL wt = 0; for (int j=0; j < N - N/2; j++) { if (i & (1<<j)) {wt += Wt[j + N/2];} } if (wt <= M) { auto it = upper_bound(Freq2.begin(), Freq2.end(), pair <LL,int> {M - wt + 1, 0}); Ways += Freq2[it - Freq2.begin() - 1].second; } } printf("%lld",Ways); }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<List.size(); i++) {
                   ~^~~~~~~~~~~~
bobek.cpp:26:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i + 1 == List.size() || List[i] != List[i+1]) {
             ~~~~~~^~~~~~~~~~~~~~
bobek.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&N,&M);
     ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &Wt[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...