题解:P14613 [2019 KAIST RUN Fall] And the Winner Is... Ourselves!
FloydNotCut · · 题解
题目分析
贪心题,很明显,罚时这一关键字其实只要在最后加上就行,我们只需要对完成时间进行排序即可。需要注意罚时的计算公式。
AC Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m;
const int N = 12;
int a[N];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int ans1 = 0, ans = 0;
n = 11;
for (int i = 1; i <= n; i++)
{
int v;
cin >> a[i] >> v;
ans1 += (v * 20);
}
sort(a+1, a+n+1);
int timer = 0;
for (int i = 1; i <= n; i++)
{
ans += (timer + a[i]);
timer += a[i];
}
cout << ans + ans1 << '\n';
return 0;
}