# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
312463 | neki | Hokej (COCI17_hokej) | C++14 | 844 ms | 33424 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 loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 26000
#define pa pair<ll, ll>
#define ld long double
vc<vc<ll>> pr, srt;
int main(){
ll m, n;cin >> m >> n;
loop(i, 1, n+1){
ll k, j;cin >> k >> j;
vc<ll> temp={k, j, i};
srt.ps(temp);
}
sort(all(srt));
ll cur=n-7;
vc<vc<ll>> kdo;
pool(i, n, n-6) kdo.ps(srt[i]);
ll ans=0;
loop(i, 1, m+1){
loop(j, 0, 6)if(kdo[j][1]==i-1){
vc<ll> temp={i-1, kdo[j][2], srt[cur][2]};
pr.ps(temp);
kdo[j]=srt[cur];
kdo[j][1]+=i;
cur--;
}
loop(j, 0, 6) ans+=kdo[j][0];
}
cout << ans<<endl;
pool(i, n, n-6) cout << srt[i][2]<<" ";cout <<endl;
cout << pr.size()<<endl;
fore(v, pr) cout << v[0]<<" "<< v[1]<<" "<< v[2]<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |