Submission #151618

# Submission time Handle Problem Language Result Execution time Memory
151618 2019-09-03T21:37:39 Z OptxPrime Hokej (COCI17_hokej) C++11
96 / 120
253 ms 24280 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long

/// 9 12
/// proso za 60/120 ne znam sta je problem

struct player{
    long long k,e,id;
    player(){}
    player( long long k, long long e,long long id ):k(k),e(e),id(id){}
} p[500010];

    vector<pair<long long,long long>> event[500010];

    bool cmp( player a, player b )
    {
            if( a.k != b.k ) return a.k>b.k;
                return a.e<b.e;
    }

int main()
{
        ios_base::sync_with_stdio(false);
            cin.tie(NULL);

            long long n,m;
            cin>>m>>n;
            for(long long i=0;i<n;i++){
                cin>>p[i].k >> p[i].e;
                p[i].id=i+1;
            }
            sort( p,p+n,cmp );
            vector<long long>citav;

             long long prev=-1,time=0,tot=0,timetotal=0,sz=0;
            for(  long long i=0;i<n;i++ ){
                ///    cout << i << " " << time << " " << prev << " " << timetotal <<  " kontas " <<endl;
                if( p[i].e==m ){
                    citav.pb( p[i].id );
                    tot+=p[i].k*m;
                    timetotal+=m;
                }
                else{
                    event[time].pb( mp( prev, p[i].id ) );
                    if(time!=0)sz++;
                    if( timetotal + p[i].e >= 6*m ){
                        tot+=p[i].k*( 6*m - timetotal );
                        break;
                    }
                    if( time + p[i].e > m ){
                        event[0].pb( mp( -1, p[i].id ) );
                    }
                        time+=p[i].e;
                        tot+=p[i].k*p[i].e;
                        timetotal+=p[i].e;
                        if( time>=m ) time-=m;
                        prev=p[i].id;
                }
            }
            cout <<tot<<endl;
            for( long long i=0;i<citav.size();i++ ) {
                    cout << citav[i] << " ";
            }

            for( long long i=0;i<event[0].size();i++ ) cout << event[0][i].second << " ";
            cout  << endl;
            cout<<sz<<endl;
            for( long long i=1;i<=m;i++ ){
                for( long long j=0;j<event[i].size();j++ ){
                    cout << i << " " << event[i][j].first << " " << event[i][j].second <<endl;
                }
            }

            return 0;
}





























Compilation message

hokej.cpp: In function 'int main()':
hokej.cpp:65:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for( long long i=0;i<citav.size();i++ ) {
                                ~^~~~~~~~~~~~~
hokej.cpp:69:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for( long long i=0;i<event[0].size();i++ ) cout << event[0][i].second << " ";
                                ~^~~~~~~~~~~~~~~~
hokej.cpp:73:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for( long long j=0;j<event[i].size();j++ ){
                                    ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 12024 KB Output is correct
2 Correct 16 ms 12152 KB Output is correct
3 Correct 25 ms 12664 KB Output is correct
4 Correct 16 ms 12024 KB Output is correct
5 Correct 29 ms 12424 KB Output is correct
6 Correct 18 ms 12208 KB Output is correct
7 Incorrect 17 ms 12280 KB Output isn't correct
8 Incorrect 75 ms 14840 KB Output isn't correct
9 Correct 252 ms 24184 KB Output is correct
10 Correct 253 ms 24280 KB Output is correct