计划补J,B,I。
J题是一道简单的模拟题,但是训练的时候还是WA了。
分类一定要分清楚,不能没想清楚就上机,越上越乱。
J题代码
// 2020-09-08 20:56:35.545006
include <bits/stdc++.h>
using namespace std;
int tim[50],rest[50],usage[50];
int a[50],b[50];
int main(){
int n=10;
for (int i=1; i<=n; ++i) scanf("%d%d",&a[i],&b[i]);
for (int i=n+1; i<=3n; ++i){
a[i]=a[(i-1)%n+1];
b[i]=b[(i-1)%n+1];
}
for (int i=1; i<=n; ++i){
scanf("%d%d%d",&usage[i],&rest[i],&tim[i]);
}
int nowtime=0;
for (int i=1; i<=3n; ++i){
int id=(i-1)%n+1;
//cerr<<"tim"<<tim[id]<<endl;
//case 1
if (nowtime<tim[id]){
tim[id]=max(nowtime+a[id],tim[id]);
nowtime+=a[id]+b[id];
}
else if ((nowtime-tim[id])%(usage[id]+rest[id])<usage[id]){
int tmp=(nowtime-tim[id])/(usage[id]+rest[id])(usage[id]+rest[id])+tim[id];
tim[id]=tmp+usage[id]+rest[id];
tim[id]=max(tim[id],tmp+usage[id]+a[id]);
nowtime=tmp+usage[id]+a[id]+b[id];
}
else{
int tmp=(nowtime-tim[id])/(usage[id]+rest[id])(usage[id]+rest[id])+tim[id];
tim[id]=tmp+usage[id]+rest[id];
tim[id]=max(tim[id],nowtime+a[id]);
nowtime+=a[id]+b[id];
}
}
cout<<nowtime-b[n]<<'\n';
}