水题求调
  • 板块学术版
  • 楼主封禁用户
  • 当前回复9
  • 已保存回复9
  • 发布时间2023/10/9 22:43
  • 上次更新2023/11/2 14:43:20
查看原帖
水题求调
750292
封禁用户楼主2023/10/9 22:43

这个

#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,m,n) for(int i=m;i<=n;i++)
using namespace std;
const int N=100005;
long long n,p[N],t[N],ans,cnt1=1,cnt2=1,tic;
bool a[N],flag;
struct node{
	int pr,en,be;
}tt[N];
int main(){
	cin>>n;
	rep(i,1,n){
		cin>>a[i]>>p[i]>>t[i];
		if(a[i]==true){
			tt[cnt2].pr =p[i];
			tt[cnt2].be =t[i];
			cnt2++;
		}
		else{
			ans+=p[i];
			tic++;
			tt[cnt1].en =t[i]+45;
			cnt1++;
		}
	}
	rep(i,1,max(cnt1,cnt2)){
		if(tic){
			if(tt[i].en >=tt[i].be ){
				tic--;
			}
			else{
				tic--;
				int ticc=tic;
				rep(j,i,ticc){
					if(tt[j].en >=tt[i].be ){
						flag=true;
						tic--;
						break;
					}
					else{
						tic--;
						continue;
					}
				}
				if(flag==false){
					ans+=tt[i].pr ;
				}
			}
		}
		else{
			ans+=tt[i].pr ;
		}
	}
	cout<<ans<<endl;
	return 0;
}

觉得没有什么问题,但是样例1都没过,少算了6,不明白漏了哪里

2023/10/9 22:43
加载中...