比赛 |
20200109 |
评测结果 |
ATTTTTTTTTTTT |
题目名称 |
Meetings |
最终得分 |
7 |
用户昵称 |
数声风笛ovo |
运行时间 |
12.000 s |
代码语言 |
C++ |
内存使用 |
14.23 MiB |
提交时间 |
2020-01-09 20:43:42 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n,l,weight;
int sta[50001][2],we[50001];
int main(){
freopen("meetings.in","r",stdin);
freopen("meetings.out","w",stdout);
cin>>n>>l;
l*=2;
for(int i=1;i<=n;++i){
cin>>we[i];
weight+=we[i];
cin>>sta[i][0]>>sta[i][1];
sta[i][0]*=2;
}
int sumwe=0;
int meet=0;
int first=1;
int last=n;
while(sumwe<weight/2){
for(int i=first;i<=last;++i){
sta[i][0]+=sta[i][1];
if(sta[i][0]==0){
++first;
sumwe+=we[i];
}else if(sta[i][0]==l){
--last;
sumwe+=we[i];
}else if(i!=first && sta[i][0]==sta[i-1][0]){
++meet;
sta[i][1]*=-1;
sta[i-1][1]*=-1;
}
}
}
cout<<meet<<endl;
return 0;
}