Submission #157929

#TimeUsernameProblemLanguageResultExecution timeMemory
157929GoldNextYearSan (COCI17_san)C++14
120 / 120
216 ms21164 KiB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #include <bits/stdc++.h> using namespace std; #define sqr 340 #define mid (l+r)/2 #define pb push_back #define ppb pop_back #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ins insert #define era erase #define C continue #define mem(dp,i) memset(dp,i,sizeof(dp)) #define mset multiset typedef long long ll; typedef long double ld; typedef pair<int,int> pi; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; const ll mod=1000000007; const ll mod2=998244353; const ll inf=1e18*4; const ld pai=acos(-1); ll n,k; ll h[49],g[49],id[49]; vpll v[2]; vll hights[29]; void bt1(ll id,ll gold,ll last){ if(id==n/2){ v[0].pb({last,gold}); return; } bt1(id+1,gold,last); if(h[id]>=last)bt1(id+1,gold+g[id],h[id]); } void bt2(ll id,ll gold,ll last,ll fi){ if(id==n){ v[1].pb({fi,gold}); return; } bt2(id+1,gold,last,fi); if(h[id]>=last){ ll xxx=fi; if(fi==inf)xxx=h[id]; bt2(id+1,gold+g[id],h[id],xxx); } } int main(){ fast; cin>>n>>k; for(int i=0;i<n;i++)cin>>h[i]>>g[i]; bt1(0,0,0); bt2(n/2,0,0,inf); for(int i=0;i<2;i++)sort(v[i].begin(),v[i].end()); ll xxx=0; for(int i=0;i<v[1].size();i++){ ll j=i; while(v[1][i].fi==v[1][j].fi && j<v[1].size())hights[xxx].pb(v[1][j++].se); sort(hights[xxx].begin(),hights[xxx].end()); id[xxx]=v[1][i].fi; xxx++; i=j-1; } ll ans=0; for(auto u:v[0]){ for(int i=0;i<xxx;i++){ if(id[i]<u.fi)C; ll x=lower_bound(hights[i].begin(),hights[i].end(),k-u.se)-hights[i].begin(); ans+=hights[i].size()-x; } } cout<<ans<<endl; }

Compilation message (stderr)

san.cpp: In function 'int main()':
san.cpp:61:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<v[1].size();i++){
                     ~^~~~~~~~~~~~
san.cpp:63:50: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 while(v[1][i].fi==v[1][j].fi && j<v[1].size())hights[xxx].pb(v[1][j++].se);
                                                 ~^~~~~~~~~~~~
#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...