QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#415480#8634. 求和akilie0 210ms11028kbC++20842b2024-05-20 22:05:152024-05-20 22:05:16

Judging History

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

  • [2024-05-20 22:05:16]
  • 评测
  • 测评结果:0
  • 用时:210ms
  • 内存:11028kb
  • [2024-05-20 22:05:15]
  • 提交

answer

#include <bits/stdc++.h> 
using namespace std; 

int main() { 
    int n; cin >> n; 
    vector<int> nums(n), check(n + 1); 
    for (int i = 0; i < n; i++) { 
        cin >> nums[i]; 
        check[nums[i]] = i; 
    }
    long long ans = 0; 
    int l = min(check[0], check[1]), r = max(check[0], check[1]); 
    if (check[0] > check[1]) 
        ans = (check[0] - check[1]) * (n - check[0]); 
    else 
        ans = (check[1] - check[0]) * (check[0] + 1); 
    for (int i = 2; i < n; i++) { 
        int idx = check[i], pidx = check[i - 1]; 
        if (l < idx and idx < r) 
            continue; 
        if (idx < l) { 
            ans += (l - idx) * i;  
            l = idx; 
            r = idx; 
        }
        // cout << i << ' ' <<ans << endl; 
    }
    cout << ans + n << endl; 
    return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7
6 2 5 1 3 0 4

output:

21

result:

wrong answer 1st numbers differ - expected: '33', found: '21'

Test #2:

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

input:

9
4 3 7 8 0 5 2 1 6

output:

37

result:

wrong answer 1st numbers differ - expected: '56', found: '37'

Test #3:

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

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:

10754

result:

wrong answer 1st numbers differ - expected: '1056340', found: '10754'

Test #4:

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

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:

17733

result:

wrong answer 1st numbers differ - expected: '67785', found: '17733'

Test #5:

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

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:

11816

result:

wrong answer 1st numbers differ - expected: '590900', found: '11816'

Test #6:

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

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:

17733

result:

wrong answer 1st numbers differ - expected: '67785', found: '17733'

Test #7:

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

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:

317357

result:

wrong answer 1st numbers differ - expected: '89784206', found: '317357'

Test #8:

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

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:

1434484

result:

wrong answer 1st numbers differ - expected: '14050945', found: '1434484'

Test #9:

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

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:

7232755

result:

wrong answer 1st numbers differ - expected: '205335278', found: '7232755'

Test #10:

score: 0
Wrong Answer
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:

1434485

result:

wrong answer 1st numbers differ - expected: '13952453', found: '1434485'

Test #11:

score: 0
Wrong Answer
time: 186ms
memory: 10876kb

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:

3592024494

result:

wrong answer 1st numbers differ - expected: '453346820756985', found: '3592024494'

Test #12:

score: 0
Wrong Answer
time: 208ms
memory: 10920kb

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:

203941661

result:

wrong answer 1st numbers differ - expected: '640456985452', found: '203941661'

Test #13:

score: 0
Wrong Answer
time: 197ms
memory: 11028kb

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:

2841652126

result:

wrong answer 1st numbers differ - expected: '122904492236287', found: '2841652126'

Test #14:

score: 0
Wrong Answer
time: 207ms
memory: 10984kb

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:

1693959939

result:

wrong answer 1st numbers differ - expected: '420320000574', found: '1693959939'

Test #15:

score: 0
Wrong Answer
time: 173ms
memory: 10960kb

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:

2557187486

result:

wrong answer 1st numbers differ - expected: '213505515788254', found: '2557187486'

Test #16:

score: 0
Wrong Answer
time: 199ms
memory: 10848kb

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:

204317976

result:

wrong answer 1st numbers differ - expected: '640472696831', found: '204317976'

Test #17:

score: 0
Wrong Answer
time: 180ms
memory: 10808kb

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:

2841652126

result:

wrong answer 1st numbers differ - expected: '122904492236287', found: '2841652126'

Test #18:

score: 0
Wrong Answer
time: 210ms
memory: 10924kb

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:

471983169

result:

wrong answer 1st numbers differ - expected: '12948507818', found: '471983169'

Test #19:

score: 0
Wrong Answer
time: 185ms
memory: 10928kb

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:

3592024494

result:

wrong answer 1st numbers differ - expected: '453346820756985', found: '3592024494'

Test #20:

score: 0
Wrong Answer
time: 193ms
memory: 10812kb

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:

471983169

result:

wrong answer 1st numbers differ - expected: '12948507818', found: '471983169'