# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
929025 | NourWael | Hokej (COCI17_hokej) | C++17 | 120 ms | 39344 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 int long long
using namespace std;
vector<pair<pair<int,int>,int>> subs;
vector<pair<pair<int,int>,int>> players;
int game[7][500005];
int ind[500005], sum;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n,m; cin>>m>>n;
for(int i=0; i<n; i++) {
int x,y; cin>>x>>y;
players.push_back({{x,y},i});
}
sort(players.begin(),players.end());
int now = n-1;
for(int i=0; i<6; i++) {
for(int min = 0; min<m; min++ ) {
if(players[now].first.second==0) now--;
game[i][min] = players[now].second;
sum += players[now].first.first;
players[now].first.second--;
}
}
cout<<sum<<'\n';
for(int i=1; i<6; i++) {
for(int min=0; min<m-1; min++) {
if(game[i][min]==game[i-1][min+1]) {
for(int j=0; j<=min; j++) swap(game[i][j],game[i-1][j]);
break;
}
}
}
for(int i=0; i<6; i++) {
for(int min=1; min<m; min++) {
if(game[i][min]!=game[i][min-1]) subs.push_back({{min, game[i][min-1]+1}, game[i][min]+1});
}
}
for(int i=0; i<6; i++) cout<<game[i][0]+1<<' ';
cout<<'\n';
cout<<subs.size()<<'\n';
sort(subs.begin(),subs.end());
for(auto it:subs) cout<<it.first.first<<' '<<it.first.second<<' '<<it.second<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |