Submission #281731

# Submission time Handle Problem Language Result Execution time Memory
281731 2020-08-23T11:47:24 Z Revo7 Hokej (COCI17_hokej) C++14
48 / 120
247 ms 65540 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define left 2*i+1
#define righ 2*i+2
#define mid (l+r)/2
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
const ll maxn=5e5+100;
const ll mod=1e9+9;
const ll base=27;

ll n,m;
struct player{
    ll val,cnt,id;
};
vector<player>a;
bool com(player a,player b){
    if(a.val==b.val){
        if(a.cnt==b.cnt)return a.id>b.id;
        return a.cnt<b.cnt;
    }
    return a.val<b.val;
}

map<ll,bool>vis[maxn];
ll pl[6][maxn];
struct sub{
    ll tim,x,y;
};

bool cmp(sub a,sub b){
    return a.tim<b.tim;
}
vector<sub>s;
int main()
{
    //setIO("threesum");
    IOS
    cin>>m>>n;
    a.resize(n);
    for(ll i=0;i<n;i++){
        cin>>a[i].val>>a[i].cnt;
        a[i].id=i+1;
    }

    sort(a.begin(),a.end(),com);
    ll tot=0;
    for(ll i=0;i<6;i++){
        for(ll j=0;j<m;j++){
            ll x=a.size()-1;
            while(x>=0&&vis[j][a[x].id])x--;
            if(x>=0){
                pl[i][j]=a[x].id;
                tot+=a[x].val;
                a[x].cnt--;
                if(!a[x].cnt)a.pop_back();
                vis[j][a[x].id]=1;
            }
        }
    }
    cout<<tot<<endl;
    for(ll i=0;i<6;i++){
        cout<<pl[i][0]<<' ';
    }
    cout<<endl;
    for(ll i=0;i<6;i++){
        for(ll j=1;j<m;j++){
            if(pl[i][j]!=pl[i][j-1]&&pl[i][j]!=0){
                s.pb({j,pl[i][j-1],pl[i][j]});
            }
        }
    }
    sort(s.begin(),s.end(),cmp);
    cout<<s.size()<<endl;
    for(auto it:s)cout<<it.tim<<' '<<it.x<<' '<<it.y<<endl;
    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 14 ms 23936 KB Output is correct
2 Correct 18 ms 25216 KB Output is correct
3 Runtime error 74 ms 65536 KB Execution killed with signal 9
4 Correct 16 ms 24704 KB Output is correct
5 Runtime error 71 ms 65540 KB Execution killed with signal 9
6 Correct 23 ms 24192 KB Output is correct
7 Incorrect 18 ms 24832 KB Output isn't correct
8 Incorrect 100 ms 48568 KB Output isn't correct
9 Runtime error 242 ms 65540 KB Execution killed with signal 9
10 Runtime error 247 ms 65540 KB Execution killed with signal 9