Submission #147371

# Submission time Handle Problem Language Result Execution time Memory
147371 2019-08-29T10:24:23 Z alexandra_udristoiu Hokej (COCI17_hokej) C++14
120 / 120
532 ms 18204 KB
#include<iostream>
#include<algorithm>
#define DIM 500005
using namespace std;
int m, n, i, j, nr, ii, jj, u;
long long sol;
int a[8][DIM];
struct str{
    int val, t, ind;
};
str v[DIM];
int cmp(str a, str b){
    return a.val > b.val;
}
int main(){
    cin>> m >> n;
    for(i = 1; i <= n; i++){
        cin>> v[i].val >> v[i].t;
        v[i].ind = i;
    }
    sort(v + 1, v + n + 1, cmp);
    ii = jj = u = 1;
    for(i = 1; i <= m * 6; i++){
        if(v[u].t == 0){
            u++;
        }
        sol += v[u].val;
        v[u].t--;
        a[ii][jj] = v[u].ind;
        jj++;
        if(jj == m + 1){
            jj = 1;
            ii++;
        }
    }
    cout<< sol <<"\n";
    for(i = 1; i <= 6; i++){
        cout<< a[i][1] <<" ";
    }
    cout<<"\n";
    for(i = 1; i <= 6; i++){
        for(j = 2; j <= m; j++){
            if(a[i][j] != a[i][j - 1] && a[i][j] != a[i + 1][j - 1]){
                nr++;
            }
        }
    }
    cout<< nr <<"\n";
    for(j = 2; j <= m; j++){
        for(i = 1; i <= 6; i++){
            if(a[i][j] != a[i][j - 1]){
                if(a[i][j] == a[i + 1][j - 1]){
                    a[i + 1][j - 1] = a[i][j - 1];
                    continue;
                }
                cout<< j - 1 <<" "<< a[i][j - 1] <<" "<< a[i][j] <<"\n";
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 8 ms 508 KB Output is correct
3 Correct 55 ms 12408 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 22 ms 5240 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 10 ms 552 KB Output is correct
8 Correct 91 ms 2812 KB Output is correct
9 Correct 532 ms 18204 KB Output is correct
10 Correct 532 ms 18188 KB Output is correct