QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#408969 | #8634. 求和 | Nelofus | 100 ✓ | 193ms | 11048kb | C++20 | 813b | 2024-05-11 13:48:05 | 2024-05-11 13:48:05 |
Judging History
answer
// Code by Heratino & Nelofus
// Narcissus & どうか安寧な記憶を
#include <bits/stdc++.h>
using i64 = long long;
//{{{誰にもなれない 私 胸張ってさ
template<typename Ta, typename Tb>
inline void chkmax(Ta &a, const Tb &b) {if (a < b) a = b;}
template<typename Ta, typename Tb>
inline void chkmin(Ta &a, const Tb &b) {if (a > b) a = b;}
//}}}
int main() {
#ifdef HeratinoNelofus
freopen("input.txt", "r", stdin);
#endif
int n;
std::cin >> n;
std::vector<int> p(n), pos(n);
for (int i = 0; i < n; i++) {
std::cin >> p[i];
pos[p[i]] = i;
}
int l = n + 1, r = -1;
i64 ans = 0;
for (int mex = 1; mex <= n; mex++) {
chkmax(r, pos[mex - 1]);
chkmin(l, pos[mex - 1]);
ans += 1ll * (l + 1) * (n - r);
}
std::cout << ans << '\n';
return 0;
}
详细
Test #1:
score: 5
Accepted
time: 0ms
memory: 3640kb
input:
7 6 2 5 1 3 0 4
output:
33
result:
ok 1 number(s): "33"
Test #2:
score: 5
Accepted
time: 0ms
memory: 3784kb
input:
9 4 3 7 8 0 5 2 1 6
output:
56
result:
ok 1 number(s): "56"
Test #3:
score: 5
Accepted
time: 0ms
memory: 3608kb
input:
298 297 296 295 294 275 292 291 142 289 288 287 286 285 284 283 282 161 280 279 278 277 276 293 274 273 272 271 270 269 268 267 266 104 264 263 262 261 260 259 198 257 256 255 254 253 252 251 250 249 123 247 246 41 244 53 240 236 235 230 226 223 221 127 219 212 27 210 209 208 207 90 205 204 201 200 ...
output:
1056340
result:
ok 1 number(s): "1056340"
Test #4:
score: 5
Accepted
time: 0ms
memory: 3608kb
input:
300 268 239 152 49 26 206 293 79 24 203 55 96 246 22 274 187 272 130 273 9 298 236 256 44 144 163 123 111 89 108 101 295 143 242 33 63 16 105 14 129 39 112 58 47 65 291 69 146 23 70 264 192 172 215 20 198 226 100 127 15 72 114 282 225 195 6 48 289 74 262 219 59 251 217 209 126 52 117 91 235 199 177 ...
output:
67785
result:
ok 1 number(s): "67785"
Test #5:
score: 5
Accepted
time: 0ms
memory: 3540kb
input:
297 280 276 272 224 270 266 265 262 261 259 258 257 256 255 254 253 252 248 245 244 215 242 240 239 238 237 235 225 223 222 221 220 217 287 243 210 208 206 205 203 107 191 23 187 186 185 184 182 180 179 178 177 176 175 174 172 170 165 163 161 159 157 153 152 151 150 149 147 145 142 141 139 137 133 1...
output:
590900
result:
ok 1 number(s): "590900"
Test #6:
score: 5
Accepted
time: 0ms
memory: 3604kb
input:
300 268 239 152 49 26 206 293 79 24 203 55 96 246 22 274 187 272 130 273 9 298 236 256 44 144 163 123 111 89 108 101 295 143 242 33 63 16 105 14 129 39 112 58 47 65 291 69 146 23 70 264 192 172 215 20 198 226 100 127 15 72 114 282 225 195 6 48 289 74 262 219 59 251 217 209 126 52 117 91 235 199 177 ...
output:
67785
result:
ok 1 number(s): "67785"
Test #7:
score: 5
Accepted
time: 0ms
memory: 3868kb
input:
4999 4910 4909 4905 4904 4900 4898 4897 4896 4894 4891 4888 4886 4884 4883 4881 4879 4878 4876 4875 747 4872 4870 4868 4867 4865 4864 4862 4858 4857 4856 4855 4852 4851 4846 4843 4842 4841 4840 4838 4836 4834 4833 4831 4830 4829 4828 4827 4826 4825 2517 4821 4820 4818 4817 4816 4815 4814 4813 4810 4...
output:
89784206
result:
ok 1 number(s): "89784206"
Test #8:
score: 5
Accepted
time: 1ms
memory: 3832kb
input:
4998 1832 4930 2892 4114 3548 4372 980 4101 2775 2241 779 3438 932 2782 3170 3237 4370 3162 1435 2997 4965 4043 791 1557 795 2616 390 3927 2310 1846 1516 535 4933 1071 2370 4594 128 4201 666 1800 4362 3889 1203 2506 1155 1722 2703 1726 810 794 4301 2832 3655 1059 1729 4829 4948 1662 4341 243 3244 67...
output:
14050945
result:
ok 1 number(s): "14050945"
Test #9:
score: 5
Accepted
time: 1ms
memory: 3572kb
input:
4996 4884 4883 4880 4877 4876 4873 4872 4871 4870 4868 4867 1554 4864 4859 4858 4857 4856 4849 4848 4846 4843 4841 4840 4838 4837 4836 4833 4829 4827 4826 4825 4819 4817 4813 4812 4810 4807 4802 4801 4799 4798 4797 4796 4795 4793 4792 4791 4789 4788 4787 4786 4784 4781 4780 4774 4773 4772 4770 4769 ...
output:
205335278
result:
ok 1 number(s): "205335278"
Test #10:
score: 5
Accepted
time: 1ms
memory: 3528kb
input:
4999 1832 4930 2892 4114 3548 4372 980 4101 2775 2241 779 3438 932 2782 3170 3237 4370 3162 1435 2997 4965 4043 791 1557 795 2616 390 3927 2310 1846 1516 535 4933 1071 2370 4594 128 4201 666 1800 4362 3889 1203 2506 1155 1722 2703 1726 810 794 4301 2832 3655 1059 1729 4829 4948 1662 4341 243 3244 67...
output:
13952453
result:
ok 1 number(s): "13952453"
Test #11:
score: 5
Accepted
time: 184ms
memory: 10892kb
input:
999998 999142 999138 999135 999133 999132 999131 999128 999127 999125 999123 999122 999121 999116 999111 999108 999105 999103 999102 999101 999099 999096 999092 999090 999089 999088 999085 999084 999083 999082 999080 999078 999076 999075 999073 999072 999070 999068 999067 999065 999064 999063 999062...
output:
453346820756985
result:
ok 1 number(s): "453346820756985"
Test #12:
score: 5
Accepted
time: 193ms
memory: 10828kb
input:
999998 573780 608453 374999 149892 905671 391303 515911 787220 13024 597466 183671 267692 602322 203119 698431 948967 428018 269311 151297 8213 371857 258337 748054 63185 569822 516690 158317 460968 764763 561512 820476 308120 665989 299288 461448 378882 816621 897864 909236 61226 825295 450849 5588...
output:
640456985452
result:
ok 1 number(s): "640456985452"
Test #13:
score: 5
Accepted
time: 185ms
memory: 10884kb
input:
1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 999959 99995...
output:
122904492236287
result:
ok 1 number(s): "122904492236287"
Test #14:
score: 5
Accepted
time: 191ms
memory: 10892kb
input:
999996 102854 632174 545589 425037 604248 560072 705933 386322 916304 161176 466245 562424 198930 652815 297443 165498 538145 802714 430847 417296 645926 474721 469090 480945 518185 262211 455185 389167 712274 882882 217005 925059 657786 869334 881654 561255 697120 678309 900212 410660 319454 802285...
output:
420320000574
result:
ok 1 number(s): "420320000574"
Test #15:
score: 5
Accepted
time: 180ms
memory: 11048kb
input:
999997 999493 999491 999489 999488 999487 999486 999485 999482 999479 999476 999474 999473 999472 999471 999470 999469 999466 999465 999464 999462 999460 999459 999456 999455 999449 999448 999447 999446 999444 999440 999439 999438 999437 999435 999433 999432 999429 999427 999426 999424 999417 999415...
output:
213505515788254
result:
ok 1 number(s): "213505515788254"
Test #16:
score: 5
Accepted
time: 189ms
memory: 10936kb
input:
999999 573780 608453 374999 149892 905671 391303 515911 787220 13024 597466 183671 267692 602322 203119 698431 948967 428018 269311 151297 8213 371857 258337 748054 63185 569822 516690 158317 460968 764763 561512 820476 308120 665989 299288 461448 378882 816621 897864 909236 61226 825295 450849 5588...
output:
640472696831
result:
ok 1 number(s): "640472696831"
Test #17:
score: 5
Accepted
time: 188ms
memory: 10940kb
input:
1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 999959 99995...
output:
122904492236287
result:
ok 1 number(s): "122904492236287"
Test #18:
score: 5
Accepted
time: 188ms
memory: 10956kb
input:
999999 884235 988504 861523 555695 833984 876468 853973 875250 10915 493469 490446 628442 817438 96931 22527 271938 19684 907164 128033 74716 334003 479052 653289 189210 825545 837077 389951 25834 798677 207112 387262 239710 243701 412148 266157 849491 414525 186093 826214 49620 121852 468444 882681...
output:
12948507818
result:
ok 1 number(s): "12948507818"
Test #19:
score: 5
Accepted
time: 175ms
memory: 11028kb
input:
999998 999142 999138 999135 999133 999132 999131 999128 999127 999125 999123 999122 999121 999116 999111 999108 999105 999103 999102 999101 999099 999096 999092 999090 999089 999088 999085 999084 999083 999082 999080 999078 999076 999075 999073 999072 999070 999068 999067 999065 999064 999063 999062...
output:
453346820756985
result:
ok 1 number(s): "453346820756985"
Test #20:
score: 5
Accepted
time: 180ms
memory: 10936kb
input:
999999 884235 988504 861523 555695 833984 876468 853973 875250 10915 493469 490446 628442 817438 96931 22527 271938 19684 907164 128033 74716 334003 479052 653289 189210 825545 837077 389951 25834 798677 207112 387262 239710 243701 412148 266157 849491 414525 186093 826214 49620 121852 468444 882681...
output:
12948507818
result:
ok 1 number(s): "12948507818"