답안 #141669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
141669 2019-08-08T18:09:03 Z Linca_Robert Hokej (COCI17_hokej) C++14
0 / 120
3 ms 632 KB
#include<bits/stdc++.h>
using namespace std;

int N, M, K, val[512], K_mx, dsp[10];
long long ans = 0;
pair< pair<int,int>, int > arr[512];
vector< pair<int,int> > player[8];
vector< pair< int, pair<int,int> > > mvs;
int main(){

    cin >> M >> N;
    for( int i = 1; i <= N; i++ ){
        cin >> arr[i].first.first >> arr[i].first.second;
        val[i] = arr[i].first.first;
        arr[i].second = i;
    }

    sort( arr + 1, arr + N + 1 );

    for( int i = 1; i <= 6; i++ )
        dsp[i] = M;

    K = 1; K_mx = 6;
    for( int i = N; i >= 1; i-- ){

        if( dsp[K] == 0 ){
            K++;
            if( K > K_mx )
                break;
        }

        if( player[K].empty() ){
            dsp[K] -= arr[i].first.second;
            player[K].push_back( { arr[i].first.second, arr[i].second } );
            continue;
        }

        if( arr[i].first.second <= dsp[K] ){
            dsp[K] -= arr[i].first.second;
            player[K].push_back( { arr[i].first.second, arr[i].second } );
        }else{

            if( arr[i].first.second == M ){
                player[K_mx].push_back( { arr[i].first.second, arr[i].second } );
                K_mx--;
                continue;
            }

            int x = arr[i].first.second - dsp[K];
            player[K].push_back( { dsp[K], arr[i].second } );
            dsp[K] = 0;
            if( K + 1 <= K_mx ){
                K++;
                player[K].push_back( { x, arr[i].second } );
                dsp[K] -= x;
            }else{
                break;
            }
        }

    }

    for( int i = 1; i <= 6; i++ ){
        for( int p = 0; p < player[i].size(); p++ ){
            ans += 1LL * player[i][p].first * val[ player[i][p].second ];
            if( p != 0 ){
                mvs.push_back( { player[i][p - 1].first, {player[i][p - 1].second, player[i][p].second} } );
            }
        }
    }

    sort( mvs.begin(), mvs.end() );

    cout << ans << "\n";
    for( int i = 1; i <= 6; i++ )
        cout << player[i][0].second << " ";
    cout << "\n" << mvs.size() << "\n";
    for( int i = 0; i < mvs.size(); i++ )
        cout << mvs[i].first << " " << mvs[i].second.first << " " << mvs[i].second.second << "\n";
    return 0;
}

Compilation message

hokej.cpp: In function 'int main()':
hokej.cpp:64:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int p = 0; p < player[i].size(); p++ ){
                         ~~^~~~~~~~~~~~~~~~~~
hokej.cpp:78:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0; i < mvs.size(); i++ )
                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 3 ms 376 KB Output isn't correct
6 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Incorrect 3 ms 376 KB Output isn't correct