45分代码,开O2 60分,求调。
查看原帖
45分代码,开O2 60分,求调。
726638
stars_fall楼主2023/10/1 08:42
#include <bits/stdc++.h>
using namespace std;
int r[10000001]={};
int d[10000001]={};
int s[10000001]={};
int t[10000001]={};
int main(){
	int n,m;
//	freopen("classroom.in","r",stdin);
//	freopen("classroom.out","w",stdout);
	freopen("p1083_10.in","r",stdin);
	freopen("p1083_10_1.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>r[i];//第i天的教室数量 
	}
	for(int i=1;i<=m;i++){
		cin>>d[i]>>s[i]>>t[i];//数量,开始,结束 
	}
	int t1=0;
	for(int i=1;i<=m;i++){
		for(int j=s[i];j<=t[i];j++){
			if(r[j]<d[i]&&t1==0){
				cout<<-1<<endl;
				cout<<i;
//				cout<<endl;
//              t1++;
//				break;
				return 0;
			}
//			if(r[j]<d[i]&&t1!=0){
//				cout<<i<<endl;
//				break;
//			}
			r[j]-=d[i];
		}
	}
	cout<<0;
	return 0;
} 
2023/10/1 08:42
加载中...