Submission #130716

#TimeUsernameProblemLanguageResultExecution timeMemory
130716nandonathanielIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
426 ms20948 KiB
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL MOD=1000000007; vector<LL> pertama,kedua; LL a[25],b[25]; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); LL n,m,ans=0; cin >> n >> m; LL first=n/2,second=n-first; for(LL i=0;i<first;i++)cin >> a[i]; for(LL i=0;i<second;i++)cin >> b[i]; for(LL i=0;i<(1<<first);i++){ LL brp=0; for(LL j=0;j<first;j++){ if(i & (1<<j))brp+=a[j]; } pertama.push_back(brp); } for(LL i=0;i<(1<<second);i++){ LL brp=0; for(LL j=0;j<second;j++){ if(i & (1<<j))brp+=b[j]; } kedua.push_back(brp); } sort(pertama.begin(),pertama.end()); sort(kedua.begin(),kedua.end()); reverse(kedua.begin(),kedua.end()); LL j=0; for(LL i=0;i<pertama.size();i++){ while(j<kedua.size() && kedua[j]+pertama[i]>m)j++; ans+=(kedua.size()-j); } cout << ans << endl; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:34:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(LL i=0;i<pertama.size();i++){
             ~^~~~~~~~~~~~~~~
bobek.cpp:35:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(j<kedua.size() && kedua[j]+pertama[i]>m)j++;
         ~^~~~~~~~~~~~~
#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...