답안 #82883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82883 2018-11-02T14:48:16 Z Milki Hokej (COCI17_hokej) C++14
0 / 120
165 ms 17316 KB
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) (int)x.size()
#define pb(x) push_back(x)

typedef long long ll;
typedef pair<int, int> point;

struct igrac{
    int k = 0, i = 0, id = 0;
    igrac(int _k, int _i, int _id){
        k = _k; i = _i; id = _id;
    }

    friend bool operator < (const igrac A, const igrac B){
        return A.k > B.k;
    }
};

vector <igrac> v, zamjene;
vector <int> postava[6];
int n, m;
int tijme[6], start[6], bio[6];

bool cmp(igrac A, igrac B){
    return A.k < B.k;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    REP(i, m){
        int a, b; cin >> a >> b;
        v.pb(igrac(a, b, i + 1));
    }
    sort(v.begin(), v.end());

    ll sol = 0;
    int l = 0, r = 5;
    for(auto &it : v){
        if(l > r) break;
        if(it.i >= n && l != r){
            sol += (ll)n * it.k;
            postava[r].pb(it.id);
            r --;
        }
        else{
            int left = n - tijme[l];
            if(it.i >= left){
                sol += (ll)left * it.k;
                if(!postava[l].empty()) zamjene.pb(igrac(tijme[l], postava[l].back(), it.id));
                postava[l].pb(it.id);
                l ++;
                if(l > r) break;

                it.i -= left;
                tijme[l] += it.i;
                sol += (ll)it.i * it.k;
                postava[l].pb(it.id);
            }
            else{
                sol += (ll)it.i * it.k;
                postava[l].pb(it.id);
                tijme[l] += it.i;
            }
        }
    }
    sort(zamjene.begin(), zamjene.end(), cmp);

    cout << sol << "\n";
    REP(i, 6)
        cout << postava[i][0] << " ";
    cout << "\n";
    cout << sz(zamjene) << "\n";
    for(auto it : zamjene){
        cout << it.k _ it.i _ it.id << "\n";
    }
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 4 ms 716 KB Output isn't correct
3 Incorrect 9 ms 1420 KB Output isn't correct
4 Incorrect 2 ms 1420 KB Output isn't correct
5 Incorrect 5 ms 1420 KB Output isn't correct
6 Incorrect 3 ms 1420 KB Output isn't correct
7 Incorrect 5 ms 1428 KB Output isn't correct
8 Incorrect 30 ms 3424 KB Output isn't correct
9 Incorrect 153 ms 12592 KB Output isn't correct
10 Incorrect 165 ms 17316 KB Output isn't correct