# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
237230 | DIvanCode | Hokej (COCI17_hokej) | C++14 | 253 ms | 7928 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<ctime>
#include<cassert>
#include<complex>
#include<string>
#include<cstring>
#include<chrono>
#include<random>
#include<bitset>
#include<iomanip>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define sz(v) (int) v.size()
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAX_N = 5e5 + 5;
int m, n;
pii a[MAX_N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> m >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i].fi >> a[i].se;
}
vector<int> order(n);
iota(all(order), 1);
sort(all(order), [&](int i, int j) {
return 1ll * a[i].fi * a[j].se < 1ll * a[i].se * a[i].fi;
});
vector<int> now_playing;
int j = 6, sum = 0;
for (int i = 0; i < 6; ++i) {
now_playing.eb(order[i]);
sum += a[order[i]].fi;
}
ll ans = 0;
vector<pair<int, pii>> subst;
for (int i = 1; i <= m; ++i) {
ans += sum;
if (i == m) {
break;
}
vector<int> new_playing;
for (int x : now_playing) {
--a[x].se;
if (!a[x].se) {
sum -= a[x].fi;
new_playing.eb(order[j]);
sum += a[order[j]].fi;
subst.eb(i, mp(x, order[j]));
++j;
} else {
new_playing.eb(x);
}
}
now_playing.swap(new_playing);
}
cout << ans << "\n";
for (int i = 0; i < 6; ++i) {
cout << order[i] << " ";
}
cout << "\n" << sz(subst) << "\n";
for (auto &pp : subst) {
cout << pp.fi << " " << pp.se.fi << " " << pp.se.se << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |