Submission details
Task:Muutokset
Sender:Lieska
Submission time:2025-11-09 01:22:34 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#2ACCEPTED0.00 s1, 2, 3details
#3ACCEPTED0.00 s1, 2, 3details
#40.00 s1, 2, 3details
#50.00 s1, 2, 3details
#6ACCEPTED0.00 s2, 3details
#70.00 s2, 3details
#80.00 s2, 3details
#90.01 s2, 3details
#10ACCEPTED0.02 s3details
#11ACCEPTED0.02 s3details
#120.02 s3details
#130.03 s3details

Code

#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
ll tr[101010], tl[101010], a[101010];
ll cnt_right[101010];
ll cumul_left[101010], cumul_right[101010];
ll ans_left=0, ans_right=0;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    
    for (int i=1; i<=m; ++i){
        cin >> a[i];
        tr[a[i]]++;
    }
    
    for (int i=1; i<=n; ++i){
        cnt_right[tr[i]]++;
    }
    for (int i=m; i>=1; --i){
        cumul_right[i] = cumul_right[i+1]+cnt_right[i];
        if (cnt_right[i]){
            ans_right+=i*((cumul_right[i+1]+1)+cumul_right[i])/2*cnt_right[i];
        }
    }
    for (int i=1; i<=m-1; ++i){
        ll b = tr[a[i]];
        ll c = tl[a[i]];
        tr[a[i]]--;
        ll d = cumul_right[b];
        ans_right -= d;
        cumul_right[b]--;
        tl[a[i]]++;
        cumul_left[c+1]++;
        ll e = cumul_left[c+1];
        ans_left += e;
        cout << ans_left + ans_right << " ";
    }   
    cout << "\n";
}
 

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: ACCEPTED

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
1000 1000 1000 1000 1000 1000 ...

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

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
1488 1488 1487 1486 1487 1488 ...

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
5106 5106 5102 5098 5097 5101 ...

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

Test 5

Group: 1, 2, 3

Verdict:

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

correct output
41676 41672 41621 41587 41589 ...

user output
41670 41666 41615 41581 41583 ...

Feedback: Incorrect character on line 1 col 5: expected "41676", got "41670"

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:

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
5278 5274 5276 5275 5271 5267 ...

Feedback: Incorrect character on line 1 col 4: expected "5279", got "5278"

Test 8

Group: 2, 3

Verdict:

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

correct output
41444 41381 41301 41284 41279 ...

user output
41435 41372 41292 41275 41270 ...

Feedback: Incorrect character on line 1 col 4: expected "41444", got "41435"

Test 9

Group: 2, 3

Verdict:

input
100000 1000
50231 31135 38003 12048 55578 ...

correct output
498503 497507 496513 495521 49...

user output
498004 497008 496014 495022 49...

Feedback: Incorrect character on line 1 col 4: expected "498503", got "498004"

Test 10

Group: 3

Verdict: ACCEPTED

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
149988 149988 149988 149988 14...

Test 11

Group: 3

Verdict: ACCEPTED

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
547169 547164 547157 547151 54...

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
4959846 4959836 4959764 495975...

Feedback: Incorrect character on line 1 col 6: expected "4959855", got "4959846"

Test 13

Group: 3

Verdict:

input
100000 100000
30941 71402 45742 82863 71830 ...

correct output
2378217706 2378191367 23781909...

user output
2378199281 2378172942 23781725...

Feedback: Incorrect character on line 1 col 5: expected "2378217706", got "2378199281"