Submission #281731

#TimeUsernameProblemLanguageResultExecution timeMemory
281731Revo7Hokej (COCI17_hokej)C++14
48 / 120
247 ms65540 KiB
#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 timeMemoryGrader output
Fetching results...