QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#303024 | #2733. Rainfall Capture | Camillus | 5 | 852ms | 3868kb | C++20 | 1.5kb | 2024-01-11 16:58:22 | 2024-01-11 16:58:23 |
Judging History
answer
#include "bits/stdc++.h"
using ll = long long;
using namespace std;
random_device rd;
mt19937_64 rnd(rd());
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
auto cost = [&]() -> int {
vector<int> left(n, -1);
vector<int> right(n, -1);
vector<int> Q;
for (int i = 0; i < n; i++) {
while (!Q.empty() && a[Q.back()] <= a[i]) {
Q.pop_back();
}
if (!Q.empty()) {
left[i] = Q.back();
}
Q.push_back(i);
}
Q.clear();
for (int i = n - 1; i >= 0; i--) {
while (!Q.empty() && a[Q.back()] < a[i]) {
Q.pop_back();
}
if (!Q.empty()) {
right[i] = Q.back();
}
Q.push_back(i);
}
int sum = 0;
for (int i = 0; i < n; i++) {
if (left[i] != -1 && right[i] != -1 && a[right[i]] != a[i]) {
sum += (right[i] - left[i] - 1) * (min(a[right[i]], a[left[i]]) - a[i]);
}
}
return sum;
};
set<int> Q;
sort(a.begin(), a.end());
while (1.l * clock() / CLOCKS_PER_SEC < 0.9l) {
shuffle(a.begin(), a.end(), rnd);
Q.insert(cost());
}
for (int x : Q) {
cout << x << " ";
}
cout << "\n";
return 0;
}
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 515ms
memory: 3660kb
input:
2 1 50
output:
0
result:
ok single line: '0 '
Test #2:
score: 0
Accepted
time: 652ms
memory: 3788kb
input:
10 50 50 1 1 1 1 1 1 1 1
output:
0 49 98 147 196 245 294 343 392
result:
ok single line: '0 49 98 147 196 245 294 343 392 '
Test #3:
score: 0
Accepted
time: 696ms
memory: 3640kb
input:
10 50 50 2 2 2 1 2 1 2 2
output:
0 1 2 48 49 50 96 97 98 144 145 146 192 193 194 240 241 242 288 289 290 337 338 386
result:
ok single line: '0 1 2 48 49 50 96 97 98 144 14...41 242 288 289 290 337 338 386 '
Test #4:
score: 0
Accepted
time: 748ms
memory: 3640kb
input:
10 50 50 3 2 3 3 3 2 3 2
output:
0 1 2 3 47 48 49 50 94 95 96 97 141 142 143 144 188 189 190 191 235 236 237 238 283 284 285 331 332 379
result:
ok single line: '0 1 2 3 47 48 49 50 94 95 96 9...37 238 283 284 285 331 332 379 '
Test #5:
score: 0
Accepted
time: 648ms
memory: 3660kb
input:
8 16 33 33 16 33 33 33 16
output:
0 17 34 51
result:
ok single line: '0 17 34 51 '
Test #6:
score: 0
Accepted
time: 724ms
memory: 3540kb
input:
9 14 45 14 50 34 24 34 14 34
output:
0 10 11 20 21 22 30 31 32 33 40 41 42 43 50 51 52 53 54 60 61 62 63 64 70 71 72 73 74 81 82 83 84 85 92 93 94 95 103 104 105 114 115 116 125 126 136 147
result:
ok single line: '0 10 11 20 21 22 30 31 32 33 4...05 114 115 116 125 126 136 147 '
Test #7:
score: 0
Accepted
time: 596ms
memory: 3788kb
input:
6 17 17 4 17 17 17
output:
0 13
result:
ok single line: '0 13 '
Test #8:
score: 0
Accepted
time: 664ms
memory: 3664kb
input:
7 36 50 50 40 43 50 40
output:
0 3 4 6 7 10 11 13 14 17 20 21 24 27 31 34 41
result:
ok single line: '0 3 4 6 7 10 11 13 14 17 20 21 24 27 31 34 41 '
Test #9:
score: 0
Accepted
time: 652ms
memory: 3656kb
input:
8 37 10 10 37 37 10 10 37
output:
0 27 54 81 108
result:
ok single line: '0 27 54 81 108 '
Test #10:
score: 0
Accepted
time: 628ms
memory: 3828kb
input:
7 24 17 4 24 4 4 24
output:
0 7 13 20 26 27 33 39 40 46 47 53 60 67
result:
ok single line: '0 7 13 20 26 27 33 39 40 46 47 53 60 67 '
Test #11:
score: 0
Accepted
time: 676ms
memory: 3660kb
input:
8 21 21 17 18 47 47 18 50
output:
0 1 3 4 6 7 10 26 27 29 30 32 33 36 52 53 55 56 58 59 62 81 82 84 85 88 110 111 114 140
result:
ok single line: '0 1 3 4 6 7 10 26 27 29 30 32 ...81 82 84 85 88 110 111 114 140 '
Test #12:
score: 0
Accepted
time: 621ms
memory: 3660kb
input:
7 9 9 23 9 23 9 9
output:
0 14 28 42 56 70
result:
ok single line: '0 14 28 42 56 70 '
Test #13:
score: 0
Accepted
time: 684ms
memory: 3648kb
input:
8 49 7 7 49 7 49 7 7
output:
0 42 84 126 168 210
result:
ok single line: '0 42 84 126 168 210 '
Test #14:
score: 0
Accepted
time: 721ms
memory: 3648kb
input:
10 18 35 41 41 18 3 35 18 18 3
output:
0 6 12 15 17 21 23 27 29 30 32 34 35 36 38 40 42 44 46 47 49 50 51 52 53 55 57 58 59 61 63 64 65 66 67 68 69 70 72 73 74 75 76 78 80 81 82 83 84 86 87 88 89 90 92 93 95 96 98 99 100 101 104 105 106 107 110 111 112 113 115 116 118 119 121 122 124 127 128 130 132 133 134 136 138 139 142 144 145 150 15...
result:
ok single line: '0 6 12 15 17 21 23 27 29 30 32...50 151 156 157 162 168 174 180 '
Test #15:
score: 0
Accepted
time: 628ms
memory: 3700kb
input:
9 7 47 47 29 7 47 7 47 47
output:
0 18 22 40 44 58 62 66 80 84 98 102 120 138
result:
ok single line: '0 18 22 40 44 58 62 66 80 84 98 102 120 138 '
Test #16:
score: 0
Accepted
time: 640ms
memory: 3656kb
input:
8 31 31 31 31 21 31 31 21
output:
0 10 20
result:
ok single line: '0 10 20 '
Test #17:
score: 0
Accepted
time: 708ms
memory: 3660kb
input:
9 35 38 48 35 35 48 18 30 30
output:
0 3 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 61 62 63 64 65 66 67 69 71 72 74 75 76 77 79 82 84 85 87 89 92 95 97 102 105 115
result:
ok single line: '0 3 5 6 8 9 10 11 12 13 14 15 ... 85 87 89 92 95 97 102 105 115 '
Test #18:
score: 0
Accepted
time: 573ms
memory: 3868kb
input:
4 43 43 43 39
output:
0 4
result:
ok single line: '0 4 '
Test #19:
score: 0
Accepted
time: 581ms
memory: 3640kb
input:
7 15 28 8 46 40 8 28
output:
0 7 12 13 14 19 20 24 25 26 27 31 32 33 37 38 39 40 44 45 49 51 52 53 56 57 63 64 65 69 76 77 81 88 89 101 113
result:
ok single line: '0 7 12 13 14 19 20 24 25 26 27...4 65 69 76 77 81 88 89 101 113 '
Test #20:
score: 0
Accepted
time: 652ms
memory: 3636kb
input:
6 37 3 3 22 35 3
output:
0 13 19 32 38 45 51 57 64 70 77 83 96 109
result:
ok single line: '0 13 19 32 38 45 51 57 64 70 77 83 96 109 '
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #21:
score: 10
Accepted
time: 780ms
memory: 3668kb
input:
50 50 50 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:
0 49 98 147 196 245 294 343 392 441 490 539 588 637 686 735 784 833 882 931 980 1029 1078 1127 1176 1225 1274 1323 1372 1421 1470 1519 1568 1617 1666 1715 1764 1813 1862 1911 1960 2009 2058 2107 2156 2205 2254 2303 2352
result:
ok single line: '0 49 98 147 196 245 294 343 39... 2107 2156 2205 2254 2303 2352 '
Test #22:
score: -10
Wrong Answer
time: 852ms
memory: 3600kb
input:
50 50 50 1 2 1 1 1 1 2 2 1 1 1 1 2 2 2 2 2 1 1 1 2 1 1 1 2 1 2 2 2 1 2 1 1 2 2 1 1 1 2 2 2 1 2 1 1 2 1 2
output:
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 59 60 62 63 64 65 66 67 68 69 70 71 72 73 74 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 251 252 253 254...
result:
wrong answer 1st lines differ - expected: '0 1 2 3 4 5 6 7 8 9 10 11 12 1...6 2232 2233 2234 2281 2282 2330', found: '11 12 13 14 15 16 17 18 19 20 ... 2232 2233 2234 2281 2282 2330 '
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%