# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165395 | theStaticMind | Hokej (COCI17_hokej) | C++14 | 346 ms | 40456 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 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++){
vector<int>L,R;
for(int j=0;j<6;j++){
ind=0;
while(ind<6){
if(matrix[ind][i]==matrix[j][i-1])break;
ind++;
}
if(ind==6)L.pb(matrix[j][i-1]);
}
for(int j=0;j<6;j++){
ind=0;
while(ind<6){
if(matrix[ind][i-1]==matrix[j][i])break;
ind++;
}
if(ind==6)R.pb(matrix[j][i]);
}
for(int j=0;j<L.size();j++){
ans.pb({i,{L[j],R[j]}});
}
}
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |