Submission details
Task:Muutokset
Sender:sharph2
Submission time:2025-11-07 21:54:58 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#20.00 s1, 2, 3details
#30.00 s1, 2, 3details
#40.00 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.40 s2, 3details
#7ACCEPTED0.41 s2, 3details
#8ACCEPTED0.42 s2, 3details
#9ACCEPTED0.39 s2, 3details
#10--3details
#11--3details
#12--3details
#13--3details

Code

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

using Z = long long int;

vector<Z> laskeAlkuosaHinnat(Z n, const vector<Z>& haut) {
    Z m = haut.size();
    vector<Z> ret(m + 1);

    // lkm[i] = montako hakua luvulle i
    vector<Z> lkm(n);

    // lkm2[i] = monellako j pätee lkm[j] = i
    vector<Z> lkm2(n + 1);
    lkm2[0] = n;

    for(Z hi = 0; hi < m; ++hi) {
        Z haku = haut[hi];
        --lkm2[lkm[haku]];
        ++lkm[haku];
        ++lkm2[lkm[haku]];

        Z v = 0;
        Z p = 0;
        for(Z i = n; i >= 0; --i) {
            for(Z j = 0; j < lkm2[i]; ++j) {
                ++p;
                v += p * i;
            }
        }
        ret[hi + 1] = v;
    }

    return ret;
}

int main() {
    Z n, m;
    cin >> n >> m;

    vector<Z> haut(m);
    for(Z& haku : haut) {
        cin >> haku;
        --haku;
    }

    vector<Z> alkuosaHinnat = laskeAlkuosaHinnat(n, haut);
    reverse(haut.begin(), haut.end());
    vector<Z> loppuosaHinnat = laskeAlkuosaHinnat(n, haut);

    for(Z i = 1; i < m; ++i) {
        cout << alkuosaHinnat[i] + loppuosaHinnat[m - i] << " ";
    }
    cout << "\n";

    return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
1 1
1

correct output
(empty)

user output
(empty)

Test 2

Group: 1, 2, 3

Verdict:

input
100 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1000 1000 1000 1000 1000 1000 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

Feedback: Incorrect character on line 1 col 2: expected "1000", got "1"

Test 3

Group: 1, 2, 3

Verdict:

input
100 1000
1 2 2 2 1 1 1 1 1 1 1 1 1 2 1 ...

correct output
1488 1488 1487 1486 1487 1488 ...

user output
1 3 4 5 7 9 10 11 12 13 14 15 ...

Feedback: Incorrect character on line 1 col 2: expected "1488", got "1"

Test 4

Group: 1, 2, 3

Verdict:

input
100 1000
7 8 2 4 8 3 3 10 9 7 7 6 8 7 2...

correct output
5107 5107 5103 5099 5098 5102 ...

user output
2486 2488 2487 2486 2487 2492 ...

Feedback: Incorrect character on line 1 col 1: expected "5107", got "2486"

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
100 1000
23 85 3 99 63 79 38 37 67 28 7...

correct output
41676 41672 41621 41587 41589 ...

user output
41676 41672 41621 41587 41589 ...

Test 6

Group: 2, 3

Verdict: ACCEPTED

input
100000 1000
2 1 2 1 1 2 2 2 1 2 2 2 2 2 2 ...

correct output
1484 1485 1484 1485 1485 1485 ...

user output
1484 1485 1484 1485 1485 1485 ...

Test 7

Group: 2, 3

Verdict: ACCEPTED

input
100000 1000
10 8 4 4 3 8 4 7 5 9 7 1 5 3 4...

correct output
5279 5275 5277 5276 5272 5268 ...

user output
5279 5275 5277 5276 5272 5268 ...

Test 8

Group: 2, 3

Verdict: ACCEPTED

input
100000 1000
82 63 63 58 57 46 58 40 23 47 ...

correct output
41444 41381 41301 41284 41279 ...

user output
41444 41381 41301 41284 41279 ...

Test 9

Group: 2, 3

Verdict: ACCEPTED

input
100000 1000
50231 31135 38003 12048 55578 ...

correct output
498503 497507 496513 495521 49...

user output
498503 497507 496513 495521 49...

Test 10

Group: 3

Verdict:

input
100000 100000
1 2 1 2 1 1 2 1 1 1 1 2 1 1 2 ...

correct output
149988 149988 149988 149988 14...

user output
(empty)

Test 11

Group: 3

Verdict:

input
100000 100000
4 2 6 2 2 2 2 5 9 5 3 5 1 9 1 ...

correct output
547169 547164 547157 547151 54...

user output
(empty)

Test 12

Group: 3

Verdict:

input
100000 100000
15 9 37 82 72 45 42 96 67 99 6...

correct output
4959855 4959845 4959773 495975...

user output
(empty)

Test 13

Group: 3

Verdict:

input
100000 100000
30941 71402 45742 82863 71830 ...

correct output
2378217706 2378191367 23781909...

user output
(empty)