2 solutions
-
0
Guest MOD
-
1
#include<bits/stdc++.h> using namespace std; struct hunmer { bool o; int money,time; }; long long n,ans,p1,m,t,num,h=1,cnt; int main() { hunmer p[100001]; cin>>n; bool x; for (int i=1; i<=n; i++) { cin>>x>>p1>>t; if (x==0) { num++; p[num].money=p1; p[num].time=t; ans+=p1; } else { cnt=0; while (t-p[h].time>45&&h<=num) { h++; } for (int j=h; j<=num; j++) { if (p[j].o==0 && p[j].money>=p1) { p[j].o=1; cnt++; break; } } if (cnt==0){ ans+=p1; } } } cout<<ans; return 0; } -
-2
#include<bits/stdc++.h> using namespace std; int a[1000005]={0}; int b[1000000]={0}; int main(){ int c=0,n,w,p,t,k=0,kf=0; cin>>n; for(int i=1;i<=n;i++){ cin>>w; cin>>p; cin>>t; for(int j=kf;j<k;j++,kf++){ if(a[j]>=t)break; } if(w==0){ a[k]=t+45; b[k]=p; k++; } else { for(int j=kf;j<=k;j++){ if(p<=b[j]){ a[j]=0; b[j]=0; p=0; break; } } } c=c+p; } cout<<c<<endl; }
- 1
Information
- ID
- 52
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 73
- Accepted
- 30
- Uploaded By