# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
79850 | pzdba | Hokej (COCI17_hokej) | C++14 | 200 ms | 10768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<pii, int> piipi;
int k[500005], l[500005];
piipi p[500005];
vector<int> ans1;
vector<piipi> ans2;
int main(){
int m, n;
scanf("%d%d", &m, &n);
for(int i=1;i<=n;i++){
scanf("%d%d", &k[i], &l[i]);
p[i] = piipi(pii(-k[i], l[i]), i);
}
sort(p+1, p+1+n);
LL ans = 0;
int cur = 1, tot = 0, pv = -1;
for(int i=1;i<=n;i++){
int idx = p[i].second;
if(tot == 0) ans1.emplace_back(idx);
else if(pv != -1) ans2.emplace_back(piipi(pii(tot, pv), idx));
tot += l[idx];
if(tot > m){
tot = tot-m;
ans += (LL)(l[idx]-tot)*k[idx];
cur++;
if(cur > 6) break;
ans += (LL)tot*k[idx];
ans1.emplace_back(idx);
}
else ans += (LL)l[idx]*k[idx];
pv = idx;
if(tot == m){
cur++;
if(cur > 6) break;
pv = -1;
tot = 0;
}
}
printf("%lld\n", ans);
for(int i=0;i<ans1.size();i++) printf("%d ", ans1[i]);
printf("\n");
sort(ans2.begin(), ans2.end());
printf("%d\n", ans2.size());
for(int i=0;i<ans2.size();i++) printf("%d %d %d\n", ans2[i].first.first, ans2[i].first.second, ans2[i].second);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |