답안 #991941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991941 2024-06-03T12:27:49 Z theboatman Hokej (COCI17_hokej) C++17
72 / 120
133 ms 23124 KB
#include <bits/stdc++.h>

using namespace std;

struct Player {
    int power;
    int stamina;
    int id;
};

struct Swap {
    int time;
    int from;
    int to;
};

void solve() {
    int m, n;
    cin >> m >> n;

    vector <Player> players(n);
    for (int i = 0; i < n; i++) {
        cin >> players[i].power >> players[i].stamina;
        players[i].id = i;
    }

    sort(players.begin(), players.end(), [](const Player &a, const Player &b) {
        return a.power > b.power;
    });

    int ykFree = 0;
    vector <int> a(6 * m);
    long long sum = 0;
    for (auto player : players) {
        while(ykFree < 6 * m && player.stamina) {
            player.stamina--;
            a[ykFree] = player.id;
            sum += player.power;

            ykFree++;
        }
    }
    vector <int> startTeam(6);
    for (int i = 0; i < 6; i++) {
        startTeam[i] = a[i * m];
    }

    vector <Swap> swaps;
    for (int i = 0; i < 6 * m; i++) {
        if (i % m == 0) {
            continue;
        }

        if (a[i - 1] != a[i]) {
            swaps.push_back({i % m - 1, a[i - 1], a[i]});
        }

    }

    sort(swaps.begin(), swaps.end(), [](const Swap &a, const Swap &b) {
        return a.time < b.time;
    });


    cout << sum << "\n";
    for (auto i : startTeam) {
        cout << i + 1 << " ";
    }
    cout << "\n";

    cout << swaps.size() << "\n";
    for (auto i : swaps) {
        cout << i.time + 1 << " " << i.from + 1 << " " << i.to + 1 << "\n"; 
    }
} 

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);

    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 18 ms 12792 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 6 ms 5212 KB Output is correct
6 Correct 1 ms 520 KB Output is correct
7 Incorrect 2 ms 604 KB Output isn't correct
8 Incorrect 17 ms 3676 KB Output isn't correct
9 Incorrect 98 ms 22956 KB Output isn't correct
10 Incorrect 133 ms 23124 KB Output isn't correct