QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#693353#9529. Farm ManagementxiaomoWA 0ms3772kbC++20687b2024-10-31 16:00:372024-10-31 16:00:37

Judging History

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

  • [2024-10-31 16:00:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2024-10-31 16:00:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef struct Node{
	ll w,l,r;
}node;
bool cmp(node a,node b){
	return a.w>b.w;
}
void solve(){
	ll n,m;cin>>n>>m;
	ll ans=0;
	vector<node> a(n);
	ll sm=0;
	for(ll i=0;i<n;i++){
		cin>>a[i].w>>a[i].l>>a[i].r;
		sm+=a[i].w;
	}
	sort(a.begin(),a.end(),cmp);
	for(ll i=0;i<n-1;i++){
		ans+=a[i].w*a[i].l;
		m-=a[i].l;
	}
	for(ll i=0;i<n;i++){
		ll c=a[i].r-a[i].l;
		if(c<=m){
			ans+=c*a[i].w;
			m-=c;
		}else{
			ans+=m*a[i].w;
			m=0;
			break;
		}
	}
	cout<<ans;
	return;
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 17
2 3 4
6 1 5
8 2 4
4 3 3
7 5 5

output:

109

result:

ok single line: '109'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

12 62
503792 9 10
607358 1 3
600501 10 10
33249 4 4
774438 6 6
197692 3 6
495807 8 8
790225 5 9
77272 3 8
494819 4 9
894779 3 9
306279 5 6

output:

35204500

result:

ok single line: '35204500'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3772kb

input:

15 32
835418 2 3
178262 1 3
527643 2 2
519710 1 1
774544 3 3
82312 1 1
808199 1 1
809396 1 3
255882 1 3
80467 1 3
874973 1 3
813965 1 2
198275 1 2
152356 1 3
802055 1 1

output:

17015002

result:

wrong answer 1st lines differ - expected: '22000255', found: '17015002'