#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
hokej.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
11 | main()
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
7 ms |
604 KB |
Output isn't correct |
3 |
Incorrect |
34 ms |
1508 KB |
Integer 45949 violates the range [1, 25002] |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
18 ms |
1608 KB |
Output isn't correct |
6 |
Incorrect |
4 ms |
716 KB |
Integer 2547 violates the range [1, 349] |
7 |
Incorrect |
9 ms |
1400 KB |
Integer 2238 violates the range [1, 1499] |
8 |
Incorrect |
136 ms |
11344 KB |
Output isn't correct |
9 |
Execution timed out |
1082 ms |
63064 KB |
Time limit exceeded |
10 |
Execution timed out |
1091 ms |
63480 KB |
Time limit exceeded |