UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198077#3455. 寇德佛斯OoXiao_QioO1006684ms24648kbC++1002b2023-11-19 14:45:372023-11-19 16:09:13

answer

#include<bits/stdc++.h>

using namespace std;

#define endl '\n'
#define hh cout<<endl;
#define No cout<<"No"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define YES cout<<"YES"<<endl;


typedef long long ll;


ll ksm(ll a,ll b)
{
    if(!b)
        return 1;
    ll ans = 1;
    while(b)
    {
        if(b&1)
            ans *= a;
        a *= a;
        b /= 2;
    }
    return ans;
}
struct node
{
    ll s,v,t;
}a[1000001];
ll n;
bool cmp(node a,node b)
{
    return b.t*a.v>b.v*a.t;
}
void solve()
{
	cin>>n;
    ll i;
    for(i=1;i<=n;i++)
        cin>>a[i].s>>a[i].v>>a[i].t;
    sort(a+1,a+1+n,cmp);
    ll s = 0,w = 0;
    for(i=1;i<=n;i++)
    {
        w += a[i].t;
        // printf("a[i].t=%d\n",a[i].t);
        s += a[i].s-w*a[i].v;
        // printf("%d %d\n",w,s);
    }
    cout<<s<<endl;
    return;
}
signed main()
{
    int T = 1;
    // cin>>T;
    while(T--)
        solve();
    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: 1208kb

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: 1208kb

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: 2ms
memory: 1236kb

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: 2ms
memory: 1240kb

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: 1236kb

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: 1348ms
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: 1934ms
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: 1787ms
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: 1611ms
memory: 24648kb

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