# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
237065 | MrRobot_28 | Hokej (COCI17_hokej) | C++17 | 411 ms | 12472 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>
using namespace std;
#define int long long
bool cmp(pair <int, pair <int, int> > a, pair <int, pair <int, int> > b)
{
if(a.first == b.first)
{
return a.second.first > b.second.first;
}
return a.first < b.first;
}
signed main() {
int m, n;
cin >> m >> n;
vector <pair <pair <int, int>, int> > x(n);
for(int i = 0; i < n; i++){
cin >> x[i].first.first >> x[i].first.second;
x[i].second = i;
}
sort(x.begin(), x.end());
reverse(x.begin(), x.end());
int sum = 0;
vector <pair <int, pair <int, int> > > ans;
vector <int> start(6);
int timer = 0;
int cnt = 1;
for(int i = 0; i < n; i++)
{
if(timer == 0)
{
sum += x[i].first.second * x[i].first.first;
timer += x[i].first.second;
start[cnt - 1] = x[i].second;
}
else if(timer + x[i].first.second > m){
if(timer != m)
{
ans.push_back({timer, {x[i - 1].second, x[i].second}});
}
sum +=(m - timer)* x[i].first.first;
if(cnt == 6)
{
timer = m;
}
else
{
cnt++;
start[cnt - 1] = x[i].second;
timer = x[i].first.second - (m - timer);
sum += timer * x[i].first.first;
}
}
else{
sum += x[i].first.second * x[i].first.first;
ans.push_back({timer, {x[i - 1].second, x[i].second}});
timer += x[i].first.second;
}
if(cnt == 6 && timer == m)
{
break;
}
}
cout << sum << "\n";
for(int i = 0; i < 6; i++)
{
cout << start[i] + 1<< " ";
}
cout << "\n";
cout << ans.size() << "\n";
sort(ans.begin(), ans.end(), cmp);
for(int i = 0; i < ans.size(); i++)
{
cout << ans[i].first << " " << ans[i].second.first + 1 << " " << ans[i].second.second + 1 << "\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |