两个样例都过了,但结果测试数据全wa了,到底什么回事,求助大佬!!
代码如下:
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int inf=1e9+7;
int n,ans,now,tt,last,last_type;
inline int read() {
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9') {
if(ch=='-')w=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
inline void write(int x) {
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
int main() {
std::ios::sync_with_stdio(false);
n=read();
while(n--) {
int u,v,w;
u=read();
v=read();
w=read();
if(u==0) {
ans+=v;
now=w;
if(last_type==0) {
tt+=w-now+45;
last+=v;
}
else tt=45,last=v;
last_type=0;
}
else if(u==1) {
if(w-now>tt||(w-now<=tt&&last<v)) ans+=v;
now=w;
last_type=1;
}
}
printf("%d",ans);
return 0;
}