CF140D New Year Contest
题意:一场比赛 让你求在比赛时间内解决问题的数量以及罚时给你一个数字n题目的数量,以及n个数字 每个问题 对应解决需要的时间然后比赛规则是 比赛时间是 18点到 次日 6点 在0点及之前提交问题 不统计罚时其中你需要在开赛后的前10分钟来分析所有的问题
问题分析:
简单的贪心。。。。原文题意真难懂,,,, sort一遍,在0点尽可能多的解决问题。 我是分了两部分 0点前 ,0 点后分别统计 别忘了 开赛后 前十分钟 需要。。。 看别人分析的 罚时可能是负数 需要取和0的最大值,,, 这种情况貌似 也确实应该有 (全部都是0点前解决了) 但是 貌似不加这个 特判也能AC
AC代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<sstream>
#include<string.h>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std
;
#define ll long long
#define lowbit(x) (x)&(-x)
#define mem(a,b) memset((a),(b),sizeof(a));
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
const ll inf
=0x3f3f3f3f;
typedef pair
<int ,int > PII
;
const int nn
=1e6+10;
int a
[nn
],mx
=0,n
;
void slove(){
int ans
=0;
int cnt
=0;
sort(a
,a
+n
);
int x
=6*60;
int xx
=10;
forn(i
,n
){
xx
+=a
[i
];
if(xx
<=x
){
ans
++;
}else break;
}
xx
-=a
[ans
];
forr(i
,ans
,n
-1){
if(xx
+a
[i
]<=720){
xx
+=a
[i
];
ans
++;
cnt
+=xx
-360;
} else break;
}
cout
<<ans
<<" "<<max(cnt
,0)<<endl
;
}
int main()
{
#ifdef io
freopen("in.txt","r",stdin);
#endif
int t
;
cin
>>n
;
forn(i
,n
) cin
>>a
[i
];
slove();
return 0;
}
转载请注明原文地址: https://lol.8miu.com/read-38813.html