社区讨论
和题解方法差不多,为什么WA了
P5661[CSP-J 2019] 公交换乘参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lobkuj12
- 此快照首次捕获于
- 2023/10/29 22:39 2 年前
- 此快照最后确认于
- 2023/11/04 03:36 2 年前
CPP
#include<cstdio>
const int MAXN=100000+5;
int n,op,price,t,ans,h,tail;
struct y{
int price,t,used;
};
y a[MAXN];
int main(){
scanf("%d",&n);
while(n--){
scanf("%d %d %d",&op,&price,&t);
if(op==0){
ans+=price;
a[tail].price=price;
a[tail].t=t+45;
tail++;
}else{
while(h<tail&&a[h].t<t)
h++;
bool flag=1;
for(int i=h;i<tail;i++){
if(a[i].price>price&&a[i].used==0){
flag=0;
a[i].used=1;
break;
}
}
if(flag){
ans+=price;
continue;
}
}
}
printf("%d",ans);
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...