Submission #86599

#TimeUsernameProblemLanguageResultExecution timeMemory
86599rzbtIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
403 ms21424 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 100005 typedef long long ll; using namespace std; ll n,m; vector<ll> tekme1,tekme2,svi1,svi2; using namespace std; int main() { scanf("%lld %lld", &n, &m); for(int i=0;i<n;i++){ ll t; scanf("%lld", &t); if(i%2==0)tekme1.pb(t); else tekme2.pb(t); } int gran=1<<tekme1.size(); for(int i=0;i<gran;i++){ ll ts=0; for(int j=0;j<tekme1.size();j++){ if((i>>j)&1)ts+=tekme1[j]; } svi1.pb(ts); } gran=1<<tekme2.size(); for(int i=0;i<gran;i++){ ll ts=0; for(int j=0;j<tekme2.size();j++){ if((i>>j)&1)ts+=tekme2[j]; } svi2.pb(ts); } sort(all(svi1)); sort(all(svi2)); ll j=svi2.size()-1,res=0; for(ll i=0;i<svi1.size();i++){ while(svi1[i]+svi2[j]>m && j>=0)j--; //printf("%lld %lld\n",i,j); if(j==-1)break; res+=j+1ll; } printf("%lld",res); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<tekme1.size();j++){
                     ~^~~~~~~~~~~~~~
bobek.cpp:36:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<tekme2.size();j++){
                     ~^~~~~~~~~~~~~~
bobek.cpp:44:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i=0;i<svi1.size();i++){
                ~^~~~~~~~~~~~
bobek.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
bobek.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &t);
         ~~~~~^~~~~~~~~~~~
#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...