Submission #1025874

#TimeUsernameProblemLanguageResultExecution timeMemory
1025874vjudge1San (COCI17_san)C++17
48 / 120
74 ms10668 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n,k; cin>>n>>k; int h[n],a[n]; for (int i=0;i<n;i++) cin>>h[i]>>a[i]; int ans=0; if (n<=20) { for (int i=0;i<(1<<n);i++) { bool b=1; int x=0,pre=0; for (int p=0;p<n;p++) if ((1<<p)&i) { if (h[p]<pre) b=0; pre=h[p]; x+=a[p]; } if (x>=k && b) ans++; } } else { int op=19; vector<pair<int,int>> vec,hf,gl; for (int i=0;i<(1<<op);i++) { bool b=1; int x=0,pre=0; for (int p=0;p<op;p++) if ((1<<p)&i) { if (h[p]<pre) b=0; pre=h[p]; x+=a[p]; } if (b) vec.push_back({pre,x}),ans+=(x>=k); } for (int i=0;i<(1<<n-op);i++) { bool b=1; int x=0,pre=0,fir=0; for (int p=0;p<n-op;p++) if ((1<<p)&i) { if (h[p+op]<pre) b=0; x+=a[p+op]; pre=h[p+op]; if (!fir) fir=h[p+op]; } if (!b) continue; } } cout<<ans<<endl; return 0; }

Compilation message (stderr)

san.cpp: In function 'int main()':
san.cpp:52:23: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   52 |   for (int i=0;i<(1<<n-op);i++)
      |                      ~^~~
#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...