QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#799176#8641. Ski 2cpchenpi#5 1ms3824kbC++201.1kb2024-12-05 01:13:402024-12-05 01:13:40

Judging History

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

  • [2024-12-05 01:13:40]
  • 评测
  • 测评结果:5
  • 用时:1ms
  • 内存:3824kb
  • [2024-12-05 01:13:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using i128 = __int128_t;

int main() {
    int n, k; cin >> n >> k;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        int h, c; cin >> h >> c;
        v[i] = {h, c};
    }
    sort(v.begin(), v.end());
    i64 ans = 0;
    // 若有多个 h 相同的点,只留下 c 最小的
    for (int i = 1; i < n; i++) {
        if (v[i].first == v[0].first) {
            ans += k;
            v[i].first++;
        }
    }
    sort(v.begin(), v.end());
    vector<int> unused(n, 1);
    // 改变 h 不优,按 h 从小到大的顺序接
    for (int i = 1; i < n; i++) {
        int minc = v[0].second;
        bool use = false;
        for (int j = 0; j < i; j++) {
            if (v[j].first < v[i].first) {
                if (unused[j]) {
                    unused[j] = 0;
                    use = true;
                    break;
                }
                minc = min(minc, v[j].second);
            }
        }
        if (!use) ans += minc;
    }
    cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 3632kb

input:

300 987761245
249 97
279 38
52 53
190 2
294 46
170 93
260 70
273 6
49 4
32 71
188 28
212 10
253 86
187 46
167 27
32 75
226 90
86 17
172 24
129 70
291 78
189 98
97 98
256 19
228 36
240 86
240 63
269 21
81 81
41 25
155 49
279 12
176 49
136 25
260 95
271 90
202 79
299 36
79 53
297 59
46 92
202 19
125 3...

output:

144

result:

ok single line: '144'

Test #2:

score: 5
Accepted
time: 1ms
memory: 3624kb

input:

300 451766134
225 3
78 77
144 26
211 37
119 39
126 65
7 47
53 7
121 37
52 60
212 24
168 60
212 42
104 45
218 4
146 42
234 25
43 83
126 67
128 61
125 80
87 62
113 8
71 28
148 80
175 34
126 77
295 91
35 62
265 31
35 29
108 8
195 34
85 59
250 41
78 62
242 17
178 80
34 15
187 60
94 34
50 25
144 29
10 8
...

output:

103

result:

ok single line: '103'

Test #3:

score: 5
Accepted
time: 1ms
memory: 3784kb

input:

300 584296612
252 63
248 8
136 92
181 38
206 77
229 21
196 84
7 86
187 29
170 42
195 10
148 100
279 2
113 65
22 18
148 68
11 14
187 72
133 59
205 7
155 95
251 76
300 18
265 19
76 59
59 76
86 7
73 84
101 49
19 47
25 70
24 44
29 75
112 77
128 27
28 27
198 29
148 56
128 89
218 26
177 13
117 84
25 91
0 ...

output:

1168593404

result:

ok single line: '1168593404'

Test #4:

score: 5
Accepted
time: 0ms
memory: 3824kb

input:

300 542226210
235 86
10 24
160 95
40 31
293 60
285 77
285 97
24 83
26 70
254 50
136 68
112 23
84 28
236 41
101 49
70 94
282 6
231 57
199 51
146 39
55 54
192 47
192 66
72 74
186 96
136 42
72 13
282 18
296 53
127 46
16 75
241 84
146 52
241 62
231 5
143 46
40 35
105 69
126 31
252 3
101 16
154 33
30 100...

output:

125

result:

ok single line: '125'

Test #5:

score: 5
Accepted
time: 0ms
memory: 3600kb

input:

300 851059749
59 76
266 2
7 58
202 53
214 58
256 30
99 28
224 16
64 80
150 93
12 14
278 15
196 7
259 97
13 27
256 100
66 90
257 26
85 44
49 64
171 63
266 37
95 44
123 75
203 41
261 89
81 30
65 51
64 42
66 45
108 10
198 45
128 86
234 49
199 77
65 37
234 52
246 8
198 12
50 3
181 71
218 83
66 85
261 73...

output:

851059869

result:

ok single line: '851059869'

Test #6:

score: 5
Accepted
time: 1ms
memory: 3780kb

input:

300 947403587
92 86
43 91
295 85
105 15
236 78
295 66
11 82
72 54
69 76
145 17
224 66
19 35
249 75
21 92
99 85
38 61
222 81
145 68
14 60
21 23
38 97
133 63
257 6
139 64
295 34
133 80
157 29
57 33
38 9
155 31
102 77
191 98
201 87
255 85
203 38
242 54
38 78
242 59
159 81
26 56
43 82
102 83
14 94
36 87...

output:

947404177

result:

ok single line: '947404177'

Test #7:

score: 5
Accepted
time: 0ms
memory: 3620kb

input:

300 363080349
19 96
23 83
20 86
22 86
7 93
12 100
21 79
14 92
15 90
19 91
23 96
16 89
20 84
8 100
22 79
21 94
20 85
19 88
11 100
22 90
22 80
2 99
23 89
21 84
23 80
8 96
9 96
23 88
17 93
16 84
11 95
22 90
18 86
11 92
19 81
18 88
9 92
12 97
4 98
17 89
23 95
5 99
10 93
18 89
10 97
16 91
8 97
16 85
20 8...

output:

363082396

result:

ok single line: '363082396'

Test #8:

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

input:

300 1000000000
300 57
300 24
300 40
300 45
300 68
300 38
300 94
300 79
300 39
300 87
300 98
300 79
300 63
300 56
300 97
300 63
300 52
300 61
300 83
300 35
300 19
300 38
300 12
300 9
300 87
300 3
300 92
300 54
300 5
300 37
300 43
300 11
300 25
300 87
300 70
300 65
300 58
300 57
300 70
300 87
300 67
3...

output:

299000000298

result:

ok single line: '299000000298'

Subtask #2:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 1ms
memory: 3620kb

input:

300 1
0 6596366
1 195480684
2 39457151
1 832234727
1 462764495
2 81049898
0 487070027
1 430671894
2 721333033
1 615885993
1 842070560
1 592116125
2 840818824
0 544935711
2 333187430
2 467111553
0 416912849
2 159079860
0 478546939
0 593053374
0 876528192
2 9215174
1 93255151
2 120891934
0 10339332
2 ...

output:

1259906005

result:

wrong answer 1st lines differ - expected: '44543', found: '1259906005'

Subtask #3:

score: 0
Wrong Answer

Test #20:

score: 9
Accepted
time: 0ms
memory: 3512kb

input:

10 849097758
4 937762392
10 817247459
0 440668594
1 912982987
7 663812156
7 594886472
0 837105766
2 737473115
3 649275922
10 873042888

output:

1289766352

result:

ok single line: '1289766352'

Test #21:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

input:

10 9998
5 878445115
0 949971639
4 896709623
3 782518625
0 763551803
2 795919483
10 820305225
7 955019709
0 988957902
6 794013355

output:

763571799

result:

wrong answer 1st lines differ - expected: '89982', found: '763571799'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%