# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472842 | MamdouhN | Hokej (COCI17_hokej) | C++14 | 1072 ms | 63924 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>
using namespace std;
#define int long long
#define endl "\n"
vector<pair<int,pair<int,int>>>ans;
vector<pair<pair<int,int>,int>>current;
vector<int>the6;
map<pair<int,int>,vector<int>>idk;
main()
{
int minutes,players;
cin>>minutes>>players;
priority_queue<pair<int,int>>pq;
for(int i=0;i<players;i++)
{
int a,b;
cin>>a>>b;
idk[{a,b}].push_back(i+1);
pq.push({a,-b});
}
int Ans = 0;
for(int i=0;i<6;i++)
{
the6.push_back(pq.top().first);
int x = pq.top().first , y =-pq.top().second;
current.push_back( { {x,y} , idk[{x,y}][0] } );
idk[{x,y}].erase(idk[{x,y}].begin());
pq.pop();
}
for(int i=0;i<minutes;i++)
{
//cout<<i<<endl;
//if(i==minutes-1)for(auto v:current)cout<<v.first.first<<" "<<v.first.second<<endl;
int quality = 0;
for(int j=0;j<6;j++)
{
current[j].first.second--;
quality+=current[j].first.first;
if(current[j].first.second==0&&i!=minutes-1)
{
int idx = current[j].second;
current.erase(current.begin()+j);
pair<int,int>x,y;
x = {pq.top().first,-pq.top().second};
pq.pop();
y = {pq.top().first,-pq.top().second};
pq.pop();
int xx = x.first * min(x.second , minutes - i);
int yy = y.first * min(y.second , minutes - i);
if(xx>yy)
{
current.insert(current.begin()+j , {x,idk[x][0]} );
pq.push({y.first,-y.second});
ans.push_back({ i + 1 , { idx, idk[x][0] }});
idk[x].erase(idk[x].begin());
}
else
{
current.insert(current.begin()+j , {y,idk[y][0]} );
pq.push({x.first,-x.second});
ans.push_back({ i + 1 , { idx, idk[y][0] }});
idk[y].erase(idk[y].begin());
}
}
}
//cout<<i<<" "<<quality<<endl;
Ans+=quality;
}
cout<<Ans<<endl;
for(auto v:the6)cout<<v<<" ";
cout<<endl;
for(auto v:ans)cout<<v.first<<" "<<v.second.first<<" "<<v.second.second<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |