Submission #55550

#TimeUsernameProblemLanguageResultExecution timeMemory
55550zelinskiIce Hockey World Championship (CEOI15_bobek)C++11
10 / 100
167 ms33696 KiB
#include <bits/stdc++.h> #define x first #define y second #define MaxN 20 #define MaxG 1048576 #define int64 long long using namespace std; int64 sum[2][MaxG+1]; int64 v[2][MaxN+1]; int64 x[MaxN+1]; int64 temp,K; int N,M,X,Y,P; int C[2]; void Solve(int l, int N) { if(!N) sum[l][ ++C[l] ] = temp; else{ temp = temp + v[l][N]; Solve(l, N-1); temp = temp - v[l][N]; Solve(l, N-1); } } int main(){ /* freopen("file.in","r",stdin); freopen("file.out","w",stdout); */ int i,j; int64 res = 0; scanf("%d %lld",&P,&K); for(i = 1; i <= P/2; ++i) scanf("%lld",&x[++N]); sort(x+1, x+N+1); for(i = 1; i <= N; ++i) v[0][i] = x[i]; for(i = (P+1)/2; i <= P; ++i) scanf("%lld",&x[++M]); sort(x+1, x+M+1); for(i = 1; i <= M; ++i) v[1][i] = x[i]; Solve(0, N); Solve(1, M); X = C[0]; Y = C[1]; sort(sum[0]+1, sum[0]+X+1); sort(sum[1]+1, sum[1]+Y+1); for(i = 1, j = Y; i <= X; ++i) { while(sum[0][i] + sum[1][j] > K && j) --j; res = res + j; } printf("%lld\n",res); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %lld",&P,&K);
     ~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:38:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i = 1; i <= P/2; ++i) scanf("%lld",&x[++N]);
                               ~~~~~^~~~~~~~~~~~~~~~
bobek.cpp:42:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i = (P+1)/2; i <= P; ++i) scanf("%lld",&x[++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...