#include <cstdio>
#include <algorithm>
using std::sort;
using std::max;
const int maxn = 105;
int n, a[maxn];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
sort(a + 1, a + 1 + n);
int now = 10, ans = 0, penalty = 0;
for (int i = 1; i <= n; i++) {
if (now + a[i] > 720) break;
ans++;
now += a[i];
penalty += max(0, now - 360);
}
return !printf("%d %d\n", ans, penalty);
}
原文:https://www.cnblogs.com/AlphaWA/p/10895741.html