Submission #46929

#TimeUsernameProblemLanguageResultExecution timeMemory
46929alex99Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
371 ms17568 KiB
#include <iostream> #include <algorithm> using namespace std; int N; long long M; long long A[(1 << 21) + 5], B[(1<< 21) + 5]; long long C[45]; void Read() { cin >> N >> M; for(int i = 1; i <= N; i++) { cin >> C[i]; } } void precalcAB() { int lim = N / 2; for(int conf = 0; conf < (1 << lim); conf++) { long long sum = 0; for(int j = 0; j < lim; j++) { if((conf & (1 << j)) != 0) sum += C[j + 1]; } A[conf] = sum; } for(int conf = 0; conf < (1 << (N - lim)); conf++) { long long sum = 0; for(int j = 0; j < N - lim; j++) { if((conf & (1 << j)) != 0) sum += C[j + lim + 1]; } B[conf] = sum; } int x = (1 << lim); int y = ((1 << (N - lim))); sort(A, A + (1 << lim)); sort(B , B + (1 << (N - lim))); int point = 0, point2 = y - 1; long long ans = 0; for(int i = 0; i < x; i++) { while(point2 >= 0 && B[point2] + A[i] > M) --point2; ans += point2 + 1; } cout << ans << '\n'; } int main() { Read(); precalcAB(); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'void precalcAB()':
bobek.cpp:44:9: warning: unused variable 'point' [-Wunused-variable]
     int point = 0, point2 = y - 1;
         ^~~~~
#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...