UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198063#3455. 寇德佛斯JuRuoError_YBW1006031ms24648kbC++758b2023-11-19 14:20:442023-11-19 16:07:56

answer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define int long long
const int MAXN=1e6+5;
int n;
struct node{
	int a,b,c;
}d[MAXN];
int cmp(node a,node b){
	double f=a.a-(a.c*a.b)+b.a-((a.c+b.c)*b.b);
	double k=b.a-(b.c*b.b)+a.a-((a.c+b.c)*a.b);
	return f>k;
}
signed main(){
	std::cin>>n;
	for(int i=1;i<=n;i++){
		std::cin>>d[i].a>>d[i].b>>d[i].c;
	}
	std::sort(d+1,d+n+1,cmp);
	int tim=0,ans=0;
	for(int i=1;i<=n;i++){
		tim+=d[i].c;
		//std::cout<<d[i].a<<' '<<d[i].b<<' '<<d[i].c<<'\n';
		ans+=d[i].a-(d[i].b*tim);
		
	}
	std::cout<<ans;
	return 0;
}

	

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1212kb

input:

10
36 2 2
30 2 1
36 3 1
31 3 2
35 2 2
36 1 1
33 3 2
33 2 2
31 1 2
31 1 1

output:

192

result:

ok single line: '192'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1212kb

input:

10
31 2 2
38 3 2
34 3 1
33 1 2
38 3 1
35 3 2
39 2 1
35 2 1
33 3 1
31 2 1

output:

207

result:

ok single line: '207'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1212kb

input:

10
40 1 1
38 3 1
33 2 2
31 3 2
36 3 2
34 1 2
30 1 1
34 2 2
31 3 2
34 1 2

output:

196

result:

ok single line: '196'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1240kb

input:

1000
821730 88 58
868878 10 49
730608 87 56
358378 21 39
321454 79 55
575454 80 54
238342 60 87
9675...

output:

-207648101

result:

ok single line: '-207648101'

Test #5:

score: 10
Accepted
time: 1ms
memory: 1244kb

input:

1000
295674 20 37
530507 83 34
315912 43 49
114140 17 70
783671 48 35
396223 84 20
848938 22 48
3692...

output:

-247786358

result:

ok single line: '-247786358'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1244kb

input:

1000
994667 17 41
106569 48 20
228079 48 41
607379 38 84
593976 40 38
216992 34 44
884581 34 65
1815...

output:

-189420208

result:

ok single line: '-189420208'

Test #7:

score: 10
Accepted
time: 1547ms
memory: 24648kb

input:

1000000
350938561 10248 10454
719096197 54692 29785
493023278 48605 127509
522828155 89768 282375
10...

output:

555671037091942707

result:

ok single line: '555671037091942707'

Test #8:

score: 10
Accepted
time: 1216ms
memory: 24648kb

input:

1000000
533136646 39620 52619
407344442 81670 65617
882824562 93220 73699
132198087 80380 73734
4328...

output:

498831005586624164

result:

ok single line: '498831005586624164'

Test #9:

score: 10
Accepted
time: 1566ms
memory: 24648kb

input:

1000000
510302022 39416 315270
389008019 18647 98158
372625845 28286 2045
846600729 81020 59062
1534...

output:

48132090766075035

result:

ok single line: '48132090766075035'

Test #10:

score: 10
Accepted
time: 1701ms
memory: 24644kb

input:

1000000
383677880 89105 53362
190432717 74283 263630
962327593 88363 82070
249763080 12408 140024
79...

output:

986732232553972626

result:

ok single line: '986732232553972626'

Extra Test:

score: 0
Extra Test Passed