답안 #379762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
379762 2021-03-19T08:52:51 Z FatihSolak Hokej (COCI17_hokej) C++17
0 / 120
157 ms 6620 KB
#include <bits/stdc++.h>
#define N 200005
using namespace std;
int st[6];
struct player{
    int k,t,pos;
    bool operator < (player other){
        return k < other.k;
    }
};
struct ch{
    int time,a,b;
    bool operator < (ch other){
        return time < other.time;
    }
};
vector<player> v;
void solve(){
    int m,n;
    cin >> m >> n;
    for(int i=1;i<=n;i++){
        int k,t;
        cin >> k >> t;
        v.push_back({k,t,i});
    }
    sort(v.rbegin(),v.rend());
    long long ans = 0;
    for(auto u:v){
        //cout << u.k << " " <<u.t << " " << u.pos << endl;
    }
    vector<ch> sub;
    int col = 0 ,last = 5;
    int cnt = 0;
    while(col <= last){
        int z = m;
        int nw = -1;
        while(z){
            auto &now = v[cnt];
            if(z!=m && now.t == m && last != col){
                st[last] = now.pos;
                ans += now.t * now.k;
                last--;
                cnt++;
                continue;
            }
            int can = min(z,now.t);
            now.t -= can;
            ans += now.k*can;
            if(!now.t)cnt++;
            if(nw == -1){
                st[col] = now.pos;
            } 
            else{
                sub.push_back({m-z+1,nw,now.pos});
            }
            z -= can;
            nw = now.pos;
        }
        col++;
    }
    cout << ans << endl;
    for(int i=0;i<6;i++){
        cout << st[i] << " ";
    }
    cout << endl<< sub.size()<<endl;
    sort(sub.begin(),sub.end());
    for(auto u:sub){
        cout << u.time << " " << u.a << " " << u.b << endl;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Compilation message

hokej.cpp: In function 'void solve()':
hokej.cpp:28:14: warning: variable 'u' set but not used [-Wunused-but-set-variable]
   28 |     for(auto u:v){
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Integer 50 violates the range [1, 49]
2 Failed 2 ms 492 KB some player fainted
3 Failed 9 ms 812 KB some player fainted
4 Failed 1 ms 364 KB some player fainted
5 Failed 6 ms 620 KB some player fainted
6 Incorrect 4 ms 492 KB Integer 350 violates the range [1, 349]
7 Incorrect 3 ms 620 KB Integer 1500 violates the range [1, 1499]
8 Failed 40 ms 2020 KB some player fainted
9 Failed 152 ms 6620 KB some player fainted
10 Failed 157 ms 6620 KB some player fainted