记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 1ms 324.0 KiB
#2 Wrong Answer 1ms 340.0 KiB
#3 Wrong Answer 1ms 328.0 KiB
#4 Wrong Answer 2ms 336.0 KiB
#5 Wrong Answer 1ms 328.0 KiB
#6 Wrong Answer 1ms 340.0 KiB
#7 Wrong Answer 2ms 332.0 KiB
#8 Wrong Answer 2ms 336.0 KiB
#9 Wrong Answer 2ms 328.0 KiB
#10 Wrong Answer 2ms 340.0 KiB
#11 Wrong Answer 2ms 328.0 KiB
#12 Wrong Answer 2ms 352.0 KiB
#13 Wrong Answer 3ms 332.0 KiB
#14 Wrong Answer 4ms 364.0 KiB
#15 Wrong Answer 10ms 408.0 KiB
#16 Wrong Answer 10ms 408.0 KiB
#17 Wrong Answer 10ms 408.0 KiB
#18 Wrong Answer 12ms 460.0 KiB
#19 Wrong Answer 12ms 468.0 KiB
#20 Wrong Answer 12ms 468.0 KiB

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+10,maxm=1e4+10;
int n,m,k,cnt,tot;
int p[maxn],tr[maxn],s[maxn],Sp[maxn],Se[maxn],S[maxn],r[maxm][3];
struct lo{
	int sum,num;
}l[maxn];
struct edge{
	int from,to,v;
}e[maxn];
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=((x<<1)+(x<<3))+c-'0';
		c=getchar();
	}
	return x*f;
}
inline int lowbit(int x){
	return x&-x;
}
inline void add(int x,int k){
	for(;x<=n;x+=lowbit(x))tr[x]+=k;
}
inline int ask(int x){
	int sum=0;
	for(;x;x-=lowbit(x))sum+=tr[x];
	return sum;
}
inline void build(int a,int b,int c){
	e[++cnt].from=a;
	e[cnt].to=b;
	e[cnt].v=c;
}
bool cmp(lo a,lo b){
	return a.sum<b.sum;	
}
inline void Init(){
	int a,b,c;
	n=read(),m=read(),k=read();
	for(int i=1;i<n;i++){
		c=read();
		build(i,i+1,c);
	}
	for(int i=1;i<=m;i++){
		c=read(),a=read(),b=read();
		r[i][2]=c;
		p[a]=max(p[a],c);
		s[a]++,s[b]--;
		r[i][0]=a;r[i][1]=b;
	}
	for(int i=1;i<=n;i++){
		add(i,s[i]);
		Sp[i]=p[i];
		if(i<n) Se[i]=Se[i-1]+e[i].v;
		if(S[i-1]<p[i])
		S[i]=p[i]+e[i].v;
		else 
		S[i]=S[i-1]+e[i].v;
	}
	for(int i=1;i<=m;i++){
		for(int j=r[i][0];j<=r[i][1];j++){
			tot+=e[i].v;
			if(tot<=p[j])
			tot+=p[j]-tot;
		}
		cout<<tot<<endl;
	}
	for(int i=1;i<n;i++){
		l[i].sum=ask(i);
		l[i].num=i;
	}
	cout<<tot<<endl;
}
inline void Work(){
	sort(l+1,l+n,cmp);
	for(int i=1;k>0&&i<n;k-=e[l[i].num].v,i++){
		if(k<e[l[i].num].v)tot-=l[i].sum*k;
		else tot-=l[i].sum*e[l[i].num].v;
	}
	printf("%d\n",tot);
}
int main(){
	Init();
	Work();
	return 0;
}

信息

递交者
类型
递交
题目
P1037 观光公交
比赛
随机真题赛第一轮(xhy&lfy讲题)
题目数据
下载
语言
C++
递交时间
2019-11-11 15:16:04
评测时间
2019-11-11 15:16:04
评测机
分数
0
总耗时
101ms
峰值内存
468.0 KiB