/ Randle /

记录详情

Runtime Error


  
# 状态 耗时 内存占用
#1 Accepted 1ms 228.0 KiB
#2 Accepted 1ms 224.0 KiB
#3 Accepted 1ms 228.0 KiB
#4 Accepted 1ms 224.0 KiB
#5 Accepted 1ms 228.0 KiB
#6 Accepted 1ms 224.0 KiB
#7 Runtime Error 1ms 228.0 KiB
#8 Runtime Error 1ms 224.0 KiB
#9 Runtime Error 1ms 228.0 KiB
#10 Runtime Error 1ms 224.0 KiB

代码

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,j,k) for (int i=j;i<=k;i++)
#define dep(i,j,k) for (int i=j;i>=k;i--)
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
int ans,n,m,k,w[1005];
struct node{
	int u,v,c;
}e[1005];
bool cmp(node a,node b){
	if(a.v!=b.v) return a.v<b.v;
	return a.u<b.u;
}
int main(){
//	freopen("bus.in","r",stdin);
//	freopen("bus.out","w",stdout);
	scanf("%d%d%d",&k,&n,&m);
	rep(i,1,k) scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].c);
	sort(e+1,e+1+k,cmp);
	rep(i,1,k){
		if(w[e[i].u]>=m) continue;
		int minn=2e9;
		rep(j,e[i].u,e[i].v){
			minn=min(m-w[j],minn);
			if(minn<=0) break;
		}
	    if(minn>0){
	    	if(minn>=e[i].c){ 
	        	rep(j,e[i].u,e[i].v-1) w[j]+=e[i].c;
	    		ans+=e[i].c;
	      	}
	    	else{
	    		rep(j,e[i].u,e[i].v-1) w[j]+=minn;
		        ans+=minn;
	      	}
		}
	}
	printf("%d\n",ans);
	return 0;
}

信息

递交者
类型
递交
题目
公交与怪兽 T2
题目数据
下载
语言
C++
递交时间
2019-11-09 19:00:24
评测时间
2019-11-09 19:00:24
评测机
分数
60
总耗时
17ms
峰值内存
228.0 KiB