Submission #141191

# Submission time Handle Problem Language Result Execution time Memory
141191 2019-08-07T06:04:01 Z Ruxandra985 Hokej (COCI17_hokej) C++14
72 / 120
210 ms 6372 KB
#include <cstdio>
#include <algorithm>
#define DIMN 500010

using namespace std;
int cmp (pair <int , pair <int,int> > x , pair <int , pair <int,int> > y){
    if (x.first != y.first)
        return x.first > y.first;
    return x.second.first < y.second.first;
}
struct idk{
    int time,idx,col;
} changes[4*DIMN];
pair <int, pair <int,int> > v[DIMN];
int last[7];
int cmp2 (idk x, idk y){
    if (x.time != y.time)
        return x.time < y.time;
    else return x.idx < y.idx;
}
int main()
{
    //freopen ("a.in" , "r" , stdin);
    //freopen ("a.out" , "w" , stdout);
    int sum, elem,start,i,n,m;
    long long score;
    scanf ("%d%d",&m,&n);
    for (i=1;i<=n;i++){
        scanf ("%d%d",&v[i].first , &v[i].second.first);
        v[i].second.second = i;
    }
    sort (v+1 , v + n + 1,cmp);
    sum = 0;
    score = 0;
    start = 1;
    elem = 0;
    for (i=1 ; i<=n ; i++){
        score = score + (long long)v[i].first * min ( v[i].second.first , m - sum);


        if (sum + min ( v[i].second.first , m - sum) == m){
            if (min ( v[i].second.first , m - sum) == m - sum){
                elem++;
                changes[elem].time = sum; /// dupa sum minute
                changes[elem].idx = v[i].second.second; /// pe asta il pui
                changes[elem].col = start;
                /// din v[i], in start pui doar m - sum
            }
            start++;
            if (start == 7)
                break;
            v[i].second.first -= min ( v[i].second.first , m - sum);
            sum = 0;
            if (v[i].second.first)
                i--;
        }
        else {
            elem++;
            changes[elem].time = sum; /// dupa sum minute
            changes[elem].idx = v[i].second.second; /// pe asta il pui
            changes[elem].col = start;
            /// pe coloana start, ai jucatorul i fully
            int ant = v[i].second.first;
            v[i].second.first -= min ( v[i].second.first , m - sum);
            sum = sum + min ( ant , m - sum);
        }

    }
    printf ("%lld\n",score);
    sort (changes+1 , changes + elem + 1, cmp2);
    int ok = 0;
    for (i=1;i<=elem;i++){
        if (changes[i].time == 0){ /// jucator initial
            printf ("%d ",changes[i].idx);
            last[changes[i].col] = changes[i].idx;
            ok++;
            if (ok == 6){
                printf ("\n%d\n",elem-6);
            }
        }
        else {
            printf ("%d %d %d\n",changes[i].time , last[changes[i].col] , changes[i].idx);
            last[changes[i].col] = changes[i].idx;
        }
    }
    return 0;
}

Compilation message

hokej.cpp: In function 'int main()':
hokej.cpp:27:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d%d",&m,&n);
     ~~~~~~^~~~~~~~~~~~~~
hokej.cpp:29:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d%d",&v[i].first , &v[i].second.first);
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 11 ms 636 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 6 ms 476 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Incorrect 5 ms 420 KB Output isn't correct
8 Incorrect 41 ms 1656 KB Output isn't correct
9 Incorrect 210 ms 6352 KB Output isn't correct
10 Incorrect 209 ms 6372 KB Output isn't correct