# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
281731 | Revo7 | Hokej (COCI17_hokej) | C++14 | 247 ms | 65540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |