| Task: | Lista |
| Sender: | Teuro |
| Submission time: | 2025-11-08 09:57:10 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | WRONG ANSWER | 0.00 s | details |
| #4 | WRONG ANSWER | 0.00 s | details |
| #5 | WRONG ANSWER | 0.00 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:31:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
31 | for (int i = 1; i <= n; i++)
| ^~~
input/code.cpp:34:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
34 | while (std::cin >> h) {
| ^~~~~Code
#include <iostream>
#include <numeric>
#include <list>
#include <algorithm>
std::list<int> luvut;
std::list<int> haettavat;
int n, m, h;
int laske_kustannus(const std::list<int>& luvut, const std::list<int>& haettavat) {
int kustannus = 0;
for (int h : haettavat) {
int askelia = 0;
for (int l : luvut) {
askelia++;
if (l == h) {
kustannus += askelia;
break;
}
}
}
return kustannus;
}
int main() {
std::cin >> n >> m;
for (int i = 1; i <= n; i++)
luvut.push_back(i);
while (std::cin >> h) {
haettavat.push_back(h);
}
for (int h : haettavat) {
auto it = std::find(luvut.begin(), luvut.end(), h);
if (it != luvut.end()) {
luvut.erase(it);
luvut.push_front(h);
}
}
int kustannus_jalkeen = laske_kustannus(luvut, haettavat);
std::cout << kustannus_jalkeen << std::endl;
for (int x : luvut) {
std::cout << x << " ";
}
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 1 1 1 |
| correct output |
|---|
| 1 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 2 3 4 5 6 7 8 9 10 11 12 13 ... |
Test 3
Verdict: WRONG ANSWER
| 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 |
|---|
| 1512 2 1 3 4 5 6 7 8 9 10 11 12 13 ... |
Test 4
Verdict: WRONG ANSWER
| 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 |
|---|
| 5404 6 5 8 3 4 10 2 9 1 7 11 12 13 ... |
Test 5
Verdict: WRONG ANSWER
| 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 |
|---|
| 47419 82 43 22 99 77 80 34 17 49 1 5... |
