#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
struct Player{
int Q,I,id;
bool operator<(Player& A){
return Q<A.Q;
}
Player(int a=0,int b=0,int c=0){
Q=a,I=b,id=c;
}
};
vector<Player> arr(1);
vector<int> A;
bool cmp(int a,int b){
return arr[a].Q<arr[b].Q;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("q.gir","r",stdin);
// freopen("q.cik","w",stdout);
int m,n;
cin>>m>>n;
for(int i=0;i<n;i++){
int a,b;
cin>>a>>b;
arr.pb(Player(a,b,i+1));
A.pb(i+1);
}
sort(all(A),cmp);
reverse(all(A));
vector<int> matrix[6];
int ind=0,cnt=0;
for(int i=0;i<6;i++){
matrix[i].resize(m);
for(int j=0;j<m;j++){
arr[A[ind]].I--;
matrix[i][j]=A[ind];
if(arr[A[ind]].I==0)ind++;
}
}
for(int i=0;i<6;i++){
for(int j=0;j<m;j++)cnt+=arr[matrix[i][j]].Q;
}
cout<<cnt<<"\n";
for(int i=0;i<6;i++)cout<<matrix[i][0]<<" ";
cout<<"\n";
vector<pair<int,ii> >ans;
for(int i=1;i<m;i++){
for(int j=0;j<6;j++){
if(matrix[j][i]!=matrix[j][i-1])ans.pb({i,{matrix[j][i-1],matrix[j][i]}});
}
}
cout<<ans.size()<<"\n";
for(int i=0;i<ans.size();i++)cout<<ans[i].first<<" "<<ans[i].second.first<<" "<<ans[i].second.second<<"\n";
}
Compilation message
hokej.cpp: In function 'int32_t main()':
hokej.cpp:63:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<ans.size();i++)cout<<ans[i].first<<" "<<ans[i].second.first<<" "<<ans[i].second.second<<"\n";
~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
760 KB |
Output is correct |
3 |
Correct |
105 ms |
25300 KB |
Output is correct |
4 |
Correct |
2 ms |
508 KB |
Output is correct |
5 |
Correct |
28 ms |
10292 KB |
Output is correct |
6 |
Correct |
3 ms |
632 KB |
Output is correct |
7 |
Incorrect |
5 ms |
1016 KB |
Output isn't correct |
8 |
Incorrect |
47 ms |
7072 KB |
Output isn't correct |
9 |
Incorrect |
287 ms |
44824 KB |
Output isn't correct |
10 |
Incorrect |
286 ms |
44808 KB |
Output isn't correct |