Submission #533296

#TimeUsernameProblemLanguageResultExecution timeMemory
533296ddy888Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
509 ms16708 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair typedef pair<int,int> pi; int N; ll M,A1[1<<20],A2[1<<20],v1[1<<20],v2[1<<20]; int main() { scanf("%d%lld",&N,&M); int t = N/2; N -= t; for (int i = 0; i < N; i++) cin >> A1[i]; for (int i = 0; i < t; i++) cin >> A2[i]; for (int i = 0; i < (1<<N); i++) { for (int j = 0; j < N; j++) { if (i&(1<<j)) v1[i] += A1[j]; } } for (int i = 0; i < (1<<t); i++) { for (int j = 0; j < t; j++) { if (i&(1<<j)) v2[i] += A2[j]; } } sort(v2,v2+(1<<t)); ll ans = 0; for (int i = 0; i < (1<<N); i++) { ll tmp = M- v1[i]; ans += upper_bound(v2,v2+(1<<t),tmp)-v2; } printf("%lld",ans); return 0; }

Compilation message (stderr)

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