QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#635654#7744. ElevatorTytytonyWA 109ms6816kbC++231.7kb2024-10-12 20:30:352024-10-12 20:30:36

Judging History

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

  • [2024-10-12 20:30:36]
  • 评测
  • 测评结果:WA
  • 用时:109ms
  • 内存:6816kb
  • [2024-10-12 20:30:35]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
#define N 100010
using namespace std;

ll n,k,lf1[N];
struct node{
	ll c,w,f;
}a[N];

bool bol(node a,node b){
	return a.f<b.f;
}



int main(){
	int T; cin>>T;
	while(T--){
		cin>>n>>k;
		for(int i=0;i<n;i++){
			cin>>a[i].c>>a[i].w>>a[i].f;
		}
		sort(a,a+n,bol);
//		for(int i=0;i<n;i++) cout<<a[i].c<<"\t";
//		cout<<endl;
//		for(int i=0;i<n;i++) cout<<a[i].w<<"\t";
//		cout<<endl;
//		for(int i=0;i<n;i++) cout<<a[i].f<<"\t";
//		cout<<endl;
		
		ll pre=-1;
		for(int i=0;i<n;i++){
			lf1[i]=pre;
			if(a[i].w==1) pre=i;
		}
//		for(int i=0;i<n;i++) cout<<lf1[i]<<"\t";
//		cout<<endl;
		ll ans=0;
		ll prek=k,pref=a[n-1].f;
		for(int i=n-1;i>=0;i--){
			ll C=a[i].c,W=a[i].w,F=a[i].f;
			if(a[i].c*a[i].w<prek){
				prek-=a[i].c*a[i].w;
				if(prek%2==1){
					int tmp=i;
					while(a[lf1[tmp]].c==0&&lf1[tmp]!=-1){
						tmp=lf1[tmp];
					}
					if(lf1[tmp]!=-1) a[lf1[tmp]].c--;
					a[i].c++;
				}
				continue;
			}
			else if(prek!=0||prek!=k){
				ans+=pref;
				a[i].c-=prek/a[i].w;
			}
			ans+=a[i].f*(a[i].c*a[i].w/k);
			ll cc=a[i].c;
//			cout<<
			a[i].c=(a[i].c*a[i].w%k)/a[i].w;
			cc=a[i].c;
			if(a[i].c*a[i].w%2==1){
				int tmp=i;
				while(a[lf1[tmp]].c==0&&lf1[tmp]!=-1){
					tmp=lf1[tmp];
				}
				if(lf1[tmp]!=-1) a[lf1[tmp]].c--;
				a[i].c++;
			}
			if(i==0&&a[i].c!=0) ans+=a[i].f;
			prek=k-a[i].c*a[i].w;
			pref=a[i].f;
			
//			cout<<ans<<"\t";
//			if(prek==0){
//				prek=k;
//				continue;
//			}
		}
//		cout<<endl;
		cout<<ans<<endl;
	}
	return 0;

}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

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:

24
100000

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 109ms
memory: 6816kb

input:

5501
8 104
5 2 3
6 2 4
5 2 3
6 2 9
8 2 4
2 1 3
7 2 4
8 2 8
1 290
3 1 1
12 12
6 1 2
1 2 2
1 1 2
1 2 4
6 1 1
1 2 5
6 1 4
4 1 4
6 2 4
6 2 5
4 2 5
4 1 4
5 334
1 1 4
1 2 3
4 2 1
5 1 1
2 1 2
13 218
5 2 3
5 1 4
1 2 1
1 2 5
3 2 2
1 1 3
4 2 2
1 2 5
2 2 1
2 1 5
3 2 1
5 2 1
1 1 4
10 260
7 2 1
5 1 1
5 2 4
6 1 6...

output:

0
0
23
0
0
0
0
0
0
0
0
0
0
7
13
0
0
0
0
0
0
0
0
0
22
0
0
0
0
0
0
0
0
0
0
0
0
10
152
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
17
0
0
0
9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
0
0
0
0
0
0
0
0
...

result:

wrong answer 1st lines differ - expected: '9', found: '0'