Submission #101755

#TimeUsernameProblemLanguageResultExecution timeMemory
101755shenxyIce Hockey World Championship (CEOI15_bobek)C++11
10 / 100
577 ms8640 KiB
#include <cstdio> #include <algorithm> #include <vector> using namespace std; int main() { int N; long long int M; scanf("%d %lld", &N, &M); long long int mycosts[N]; for (int i = 0; i < N; i++) scanf("%lld", &mycosts[i]); vector<long long int> thecosts; for (long long int mask = 0; mask < (1 << (N / 2)); mask++) { long long int ans = 0; for (int i = 0; i < N / 2; i++) { if (mask & (1 << i)) ans += mycosts[i]; } thecosts.push_back(ans); } sort(thecosts.begin(), thecosts.end()); long long int trueans = 0; for (long long int mask = 0; mask < (1 << (N - N / 2)); mask++) { long long int ans = 0; for (int i = 0; i < N - N / 2; i++) { if (mask & (1 << i)) ans += mycosts[i]; } trueans += upper_bound(thecosts.begin(), thecosts.end(), M - ans) - thecosts.begin(); } printf("%lld", trueans); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %lld", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:10:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < N; i++) scanf("%lld", &mycosts[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...