Submission details
Task:Lista
Sender:Grez
Submission time:2025-11-08 00:08:03 +0200
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails

Code

#include <iostream>
#include <algorithm>

using namespace std;

struct Num {
    int N;
    int C;
};

bool numdesc(const Num& a, const Num& b) { return a.C > b.C; }

int main()
{
    int nums;
    int tests;
    Num* lus;

    cin >> nums;
    cin >> tests;

    lus = new Num[nums];
    for (int i = 0; i < nums; i++) {
        Num nn;
        nn.C = 0;
        nn.N = i + 1;
        lus[i] = nn;
    }

    int test;
    for (int i=0;i<tests; i++) {
        cin >> test;
        lus[test - 1].C++;
    }

    sort(lus, lus+nums, numdesc);

    int effort = 0;
    for (int i = 0; i < nums; i++) {
        Num nn = lus[i];
        if (nn.C == 0) break;
        effort += (i + 1) * nn.C;
    }
    cout << effort << endl;
    for (int i = 0; i < nums; i++) {
        if (i) { cout << ' '; }
        cout << lus[i].N;
    }
    cout << endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
1 1
1

correct output
1

user output
1
1

Test 2

Verdict: ACCEPTED

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

correct output
1000
1 100 99 98 97 96 95 94 93 92 ...

user output
1000
1 75 76 74 73 72 71 70 69 68 6...

Test 3

Verdict: ACCEPTED

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

correct output
1488
1 2 100 99 98 97 96 95 94 93 9...

user output
1488
1 2 75 52 74 73 72 71 70 69 68...

Test 4

Verdict: ACCEPTED

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

correct output
5109
3 8 7 5 1 6 2 4 9 10 100 99 98...

user output
5109
3 8 7 5 1 6 2 4 9 10 67 77 68 ...

Test 5

Verdict: ACCEPTED

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

correct output
41714
57 38 63 62 93 85 95 81 79 61 ...

user output
41714
38 57 63 62 93 85 25 26 50 20 ...