QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580793#9370. Gambling on Choosing RegionalsportagAC ✓133ms16992kbC++231.2kb2024-09-21 23:54:552024-09-21 23:54:59

Judging History

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

  • [2024-09-21 23:54:59]
  • 评测
  • 测评结果:AC
  • 用时:133ms
  • 内存:16992kb
  • [2024-09-21 23:54:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
pair<string, int> mp[N];
int vv[N];
string tp[N];

bool cmp(pair<string, int> a, pair<string, int> b)
{
    return a.second > b.second;
}

int main()
{
    int n, m;
    cin >> n >> m;
    int mig = 0x3f3f3f3f;
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        mig = min(mig, x);
    }
    map<string, int> mp;
    vector<array<int, 3>> team(n);
    for (int i = 0; i < n; i++)
    {
        int w;
        string s;
        cin >> w >> s;
        if (mp.count(s) == 0)
        {
            mp[s] = m++;
        }
        team[i] = {w, mp[s], i};
    }

    sort(team.begin(), team.end());
    vector<int> cnt(m);
    for (auto [c, i, id] : team)
        cnt[i]++;

    int rank = 0;
    for (int i = 0; i < m; i++)
    {
        rank = rank + min(cnt[i], mig);
    }

    vector<int> ans(n);
    for (int i = 0; i < n; i++)
    {
        auto [c, j, id] = team[i];
        ans[id] = rank;
        rank = rank - min(mig, cnt[j]);
        cnt[j] = cnt[j] - 1;
        rank = rank + min(mig, cnt[j]);
    }

    for (int i = 0; i < n; i++)
        cout << ans[i] << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 11216kb

input:

5 3
1 2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

2
1
2
2
1

result:

ok 5 lines

Test #2:

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

input:

5 2
2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

4
2
4
3
1

result:

ok 5 lines

Test #3:

score: 0
Accepted
time: 93ms
memory: 12528kb

input:

100000 100000
57148 51001 13357 71125 98369 67226 49388 90852 66291 39573 38165 97007 15545 51437 89611 41523 27799 15529 16434 44291 47134 90227 26873 52252 41605 21269 9135 55784 70744 17563 79061 73981 70529 35681 91073 52031 23811 79501 1607 46365 76868 72137 71041 29217 96749 46417 40199 55907 ...

output:

1000
999
1000
1000
1000
1000
1000
1000
1000
869
1000
958
1000
1000
1000
1000
999
1000
1000
1000
1000
1000
1000
990
1000
1000
1000
631
1000
1000
1000
956
1000
1000
1000
1000
1000
1000
575
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
993
1000
1000
999
1000
995
1000
1...

result:

ok 100000 lines

Test #4:

score: 0
Accepted
time: 77ms
memory: 12460kb

input:

100000 100000
67147 61000 23356 81124 108368 77225 59387 100851 76290 49572 48164 107006 25544 61436 99610 51522 37798 25528 26433 54290 57133 100226 36872 62251 51604 31268 19134 65783 80743 27562 89060 83980 80528 45680 101072 62030 33810 89500 11606 56364 86867 82136 81040 39216 106748 56416 5019...

output:

38094
68893
8008
72205
14144
6830
48242
54784
24827
22671
69968
63405
42977
34955
37074
72306
21663
58078
74211
68516
24344
37264
47307
18059
34775
56816
64113
72997
71482
13161
47439
48057
22609
73410
55895
53054
66205
5075
27380
71695
15008
61428
73978
50256
39523
68470
73731
20025
19546
73505
345...

result:

ok 100000 lines

Test #5:

score: 0
Accepted
time: 133ms
memory: 16992kb

input:

100000 100000
67147 61000 23356 81124 108368 77225 59387 100851 76290 49572 48164 107006 25544 61436 99610 51522 37798 25528 26433 54290 57133 100226 36872 62251 51604 31268 19134 65783 80743 27562 89060 83980 80528 45680 101072 62030 33810 89500 11606 56364 86867 82136 81040 39216 106748 56416 5019...

output:

26423
58937
26692
18521
54201
5354
99663
82451
25938
1683
19896
32088
3405
89911
19509
52739
19100
40454
5716
95198
37696
50581
75919
87382
10649
31531
40292
99554
7978
38455
31927
65170
12629
30610
12082
35639
9227
28959
27742
92620
7959
54392
13253
95233
13786
72724
30709
19341
63740
24682
66206
2...

result:

ok 100000 lines

Test #6:

score: 0
Accepted
time: 59ms
memory: 12228kb

input:

100000 1
57247
892690681 MWCYSYYCQP
688582181 QGHUMEAYLN
786575036 CXGGBWKFNQ
565413377 GXRPNRVYST
326676321 CXGGBWKFNQ
2384645 MWCYSYYCQP
590490190 IMKKASVWSR
988561901 EVIKEFFMZN
133742913 GXRPNRVYST
746788385 IMKKASVWSR
357437085 QGHUMEAYLN
873729521 MWCYSYYCQP
573297441 EVIKEFFMZN
671955105 SRTK...

output:

10732
31009
21255
43584
67241
99736
41027
1135
86570
25179
64139
12590
42769
32609
75833
56599
38288
37039
58315
58503
87788
27738
48076
69908
51542
37085
87819
43841
34588
42723
31619
32181
28755
57041
15301
4840
8344
13188
92864
45975
58723
57617
56869
4451
21644
16397
16133
3186
24829
76743
26538...

result:

ok 100000 lines

Test #7:

score: 0
Accepted
time: 69ms
memory: 12412kb

input:

100000 100000
67147 61000 23356 81124 108368 77225 59387 100851 76290 49572 48164 107006 25544 61436 99610 51522 37798 25528 26433 54290 57133 100226 36872 62251 51604 31268 19134 65783 80743 27562 89060 83980 80528 45680 101072 62030 33810 89500 11606 56364 86867 82136 81040 39216 106748 56416 5019...

output:

10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
141
10000
10000
10000
10000
7459
2522
10000
10000
10000
10000
10000
10000
10000
8382
10000
10000
10000
7063
10000
10000
10000
9395
10000
10000
10000
10000
10000
10000
10000
1...

result:

ok 100000 lines

Test #8:

score: 0
Accepted
time: 76ms
memory: 12540kb

input:

100000 100000
57157 51010 13366 71134 98378 67235 49397 90861 66300 39582 38174 97016 15554 51446 89620 41532 27808 15538 16443 44300 47143 90236 26882 52261 41614 21278 9144 55793 70753 17572 79070 73990 70538 35690 91082 52040 23820 79510 1616 46374 76877 72146 71050 29226 96758 46426 40208 55916 ...

output:

100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
...

result:

ok 100000 lines

Test #9:

score: 0
Accepted
time: 68ms
memory: 12456kb

input:

100000 100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
85
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
1...

result:

ok 100000 lines

Test #10:

score: 0
Accepted
time: 105ms
memory: 13428kb

input:

100000 100000
100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000...

output:

93097
91814
38006
61839
11012
28922
7176
11638
39972
91704
22513
6492
90873
78689
16779
66673
30564
59120
23519
38548
58983
82936
47364
72728
83939
2977
49333
72995
83976
98401
63874
57879
19805
90447
53231
7802
65903
34770
98249
67629
67368
28419
76346
27926
2389
5179
91654
84769
95112
63872
71438
...

result:

ok 100000 lines

Extra Test:

score: 0
Extra Test Passed