QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#636068#7744. ElevatorYurilyWA 0ms3640kbC++201.5kb2024-10-12 22:04:372024-10-12 22:04:39

Judging History

你现在查看的是最新测评结果

  • [2024-10-12 22:04:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3640kb
  • [2024-10-12 22:04:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+5;
int T;
struct node{
	long long h,num,w;
};
node c[MAX];
int n,p;
long long k;
void findodd(){
	while(p<=n&&!(c[p].w==1&&c[p].num))
		p++;
}
// 快读 
long long read(){
	long long 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*10+c-'0';
		c = getchar();
	}
	return x*f;
}
bool cmp(node x,node y){
	return x.h>y.h;
}
void solve(){
	n=read(),k=read();
	for(int i=1;i<=n;++i){
		c[i].num=read(),c[i].w=read(),c[i].h=read();
	}
	sort(c+1,c+1+n,cmp);
	cout<<"***"<<endl;
	for(int i=1;i<=n;++i)
		cout<<c[i].num<<" "<<c[i].w<<" "<<c[i].h<<endl;
	int cur=0;
	p=1;
	long long ans=0;
	while(cur<n){
		if(c[cur+1].num==0){
			cur++;
			continue;
		}
		
		long long sum=0;
		if(c[cur+1].num*c[cur+1].w<=k){
			ans+=c[cur+1].h;
			long long sum=0;
			while(cur<n&&sum+c[cur+1].num*c[cur+1].w<=k){
				sum+=c[cur+1].num*c[cur+1].w;
				c[cur+1].num=0;
				cur++;
			}
		//	cout<<cur<<endl;
			long long t=k-sum;
			if(cur<n){
				long long cnt=t/c[cur+1].w;
				c[cur+1].num-=cnt;
				sum+=c[cur+1].w*cnt;
				if(sum<k){
					
					findodd();
					if(p!=n+1){
						c[p].num--;
					}
				}
			}
		}
		else{
			long long t=c[cur+1].num*c[cur+1].w/k;
			ans+=c[cur+1].h*t;
			c[cur+1].num-=t*k/c[cur+1].w;
		}		
	}
	
	cout<<ans<<endl;
}
int main(){
	cin>>T;
	while(T--){
		solve();
	}
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3640kb

input:

2
4 6
1 1 8
7 2 5
1 1 7
3 2 6
8 1200000
100000 1 100000
100000 1 12345
100000 2 100000
100000 2 12345
100000 1 100000
100000 1 12345
100000 2 100000
100000 2 12345

output:

***
1 1 8
1 1 7
3 2 6
7 2 5
24
***
100000 1 100000
100000 2 100000
100000 1 100000
100000 2 100000
100000 1 12345
100000 2 12345
100000 1 12345
100000 2 12345
100000

result:

wrong answer 1st lines differ - expected: '24', found: '***'