Submission #141184

# Submission time Handle Problem Language Result Execution time Memory
141184 2019-08-07T05:52:55 Z Ruxandra985 Hokej (COCI17_hokej) C++14
60 / 120
211 ms 11204 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()
{
    //FILE *fin = fopen ("a.in","r");
    //FILE *fout = fopen ("a.out","w");
    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 + 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 348 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Failed 11 ms 856 KB the answer doesn't match with the value Z
4 Correct 2 ms 352 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Incorrect 5 ms 448 KB Output isn't correct
8 Incorrect 42 ms 2388 KB Output isn't correct
9 Incorrect 209 ms 11128 KB Output isn't correct
10 Incorrect 211 ms 11204 KB Output isn't correct