QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#688708#7744. ElevatorTime_stopRE 0ms3596kbC++17675b2024-10-30 12:51:182024-10-30 12:51:18

Judging History

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

  • [2024-10-30 12:51:18]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3596kb
  • [2024-10-30 12:51:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

bool cmp(pair<ll,ll> a,pair<ll,ll> b){
	return a.first>=b.first;
}


void solve(){
	ll n,k;
	vector<pair<ll,ll> > a;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		a.push_back({z,x*y});
	}
	a.push_back({0,1});
	sort(a.begin(),a.end(),cmp);
	ll ans=0;
	ll now=a[0].first,sum=0;
	for(auto it:a){
		sum+=it.second;
	   if(sum>k){
	   	  ans+=now;
	   	  sum-=k;
	   	  now=it.first;
	   	  ll c=(sum-1)/k;
	   	  ans=ans+c*now;
	   	  sum=sum-c*k;
	   }
	}
	ans+=now;
	cout<<ans<<endl;
}


int main(){
	int t;
	cin>>t;
	while(t--){
		solve();
	}
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Runtime Error

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:

9
1
23
4
5
7
1

result: