对于每组数据,先输出一行Case #i:
(1≤i≤T) ?
如果百小度能打败所有的ACMer,再输出"why am I so diao?"?
否则再输出"madan!"
思路就是贪心,对acmer排序,每次找到不大于赛亚人的最大战力,在此基础上加k直到不能再加为止
代码如下
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
using namespace std;
#define LL long long
const int maxn = 10000 + 100;
const int INF = 0x3f3f3f3f;
//freopen("input.txt", "r", stdin);
LL acm[maxn];
bool solve(int n, LL k, LL m) {
sort(acm, acm + n);
LL zhandouli = m, maxacm = acm[n - 1], maxt = -1;
for(int i = 0; i < n && k > 0; i++, k--) {
int tmp = upper_bound(acm, acm + n, zhandouli) - acm - 1;
if(tmp <= maxt) {
//cout << zhandouli << endl;
if(zhandouli >= maxacm) return true;
else return false;
}
zhandouli = acm[tmp] + k;
maxt = tmp;
}
//cout << zhandouli << endl;
if(zhandouli >= maxacm) return true;
else return false;
}
int main() {
int T, kase = 0; scanf("%d", &T);
while(T--) {
int n; scanf("%d", &n);
LL m, k; cin >> m >> k;
for(int i = 0; i < n; i++) cin >> acm[i];
printf("Case #%d:\n", ++kase);
if(solve(n, k, m)) printf("why am I so diao?\n");
else printf("madan!\n");
}
return 0;
}