题目链接
题意很长,先翻译一下:
由N个参赛队伍,给出其余N-1只参赛队伍,另外一支队伍是我们。本次ICPC一共有10道题,我们知道其余N支队伍每道题的通过时间和错误次数,如果是"-"则为没有在300分钟内解决该问题。最后给出我们队伍:做出每道题的所需的时间,以及所需要的提交错误的次数,(他是先知,知道自己要是做这道题会WA几次才A)。好了,规则说的差不多明白了,现在来说我们要做的是什么?——让快乐值最高!!!
快乐值:
- 某题一血+800(最快解题奖)
- 全场一血+700(在某题一血的基础上)
- 最后一滴血+500(顽强拼搏奖)
- 排名加分+5000/rank
- 金奖+1200(前10%)
- 银奖+800(前30%)
- 铜奖+400(前60%)
那么,我们想要知道我们最多可以有多快乐!
我们可以枚举过题的顺序,那么最坏情况就是。
接下去,对于每道题的信息查询是否是最快的,以及最后交题的时间是否是最后一个的,这个可以是O(10)的判断的。
但是排名我们应该如何去求,对于其余N-1个点,是有线性关系的,也就是其余N-1个点的排名相互是固定的,所以我们可以使用预处理+二分答案的方式来进行查询(降低复杂度)。
总复杂度
给几组测试样例
10
233 1,-,-,7 7,257 4,173 5,117 1,-,-,85 3
-,231 0,167 0,257 7,-,-,122 4,283 0,\215 4,-
41 1,-,290 8,-,-,-,-,246 7,120 3,184 9
142 8,243 7,69 0,-,41 9,-,279 1,264 4,-,74 9
53 8,-,187 9,60 1,48 8,99 10,-,-,55 7,259 5
250 0,-,-,-,166 0,16 3,-,82 4,73 0,184 3
-,-,-,-,105 3,-,-,-,152 4,-
-,84 5,98 8,-,120 8,241 3,94 1,-,28 7,109 8
280 6,246 5,58 9,-,-,-,-,-,-,-
38 10,-,227 10,187 9,182 1,-,1 9,254 7,-,-
ans:3425
10
1 0,1 0,-,-,-,-,-,-,-,-
2 0,2 0,3 0,1 0,-,-,-,-,-,-
-,-,-,-,-,-,-,3 0,-,-
-,-,-,-,-,-,-,-,-,-
5 0,-,-,-,-,4 0,-,-,-,-
6 0,-,-,-,-,-,-,-,-,-
7 0,-,-,-,-,-,-,-,-,-
8 0,-,-,-,-,-,-,-,-,-
9 0,-,-,-,-,-,-,-,-,-
300 0,1 0,1 0,-,-,-,-,-,-,-
ans:4800
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <limits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
//#include <unordered_map>
//#include <unordered_set>
#define lowbit(x) ( x&(-x) )
#define pi 3.141592653589793
#define e 2.718281828459045
#define INF 0x3f3f3f3f
#define HalF (l + r)>>1
#define lsn rt<<1
#define rsn rt<<1|1
#define Lson lsn, l, mid
#define Rson rsn, mid+1, r
#define QL Lson, ql, qr
#define QR Rson, ql, qr
#define myself rt, l, r
using namespace std;
typedef unsigned long long ull;
typedef unsigned int uit;
typedef long long ll;
inline bool lessthan(int e1, int e2) { return e1 > e2; }
inline bool is_num(int ch) { return ch >= '0' && ch <= '9'; }
inline int read(int &x)
{
char ch = getchar();
while((ch ^ '-') && !is_num(ch)) ch = getchar();
if(ch == '-') { x = -1; return x; }
x = ch - '0';
while(is_num(ch = getchar())) x = x * 10 + ch - '0';
return x;
}
const int maxN = 305;
int N;
int done_Time[maxN][10], Wa_num[maxN][10], cnt[maxN], pen_time[maxN], solve_time[maxN][10];
int need_time[10], need_wa[10];
int minn_solve_all, minn_solve[10], maxx_solve_all;
inline bool cmp(int e1, int e2)
{
if(cnt[e1] ^ cnt[e2]) return cnt[e1] > cnt[e2];
if(pen_time[e1] ^ pen_time[e2]) return pen_time[e1] < pen_time[e2];
for(int i=0; i<cnt[e1]; i++) if(solve_time[e1][i] ^ solve_time[e2][i]) return solve_time[e1][i] < solve_time[e2][i];
return e1 > e2;
}
int perm[10], cnt_N, other_rank[maxN];
inline int Get_Rank()
{
int l = 1, r = N - 1, ans = 0, mid;
while(l <= r)
{
mid = HalF;
if(cmp(N, other_rank[mid])) r = mid - 1;
else
{
l = mid + 1;
ans = mid;
}
}
return ans + 1;
}
inline void init()
{
minn_solve_all = INF; maxx_solve_all = 0; cnt_N = 0;
for(int i=0; i<10; i++) minn_solve[i] = INF;
}
int main()
{
read(N);
init();
for(int i=1; i<N; i++)
{
cnt[i] = pen_time[i] = 0;
for(int j=0; j<10; j++)
{
if(~read(done_Time[i][j]))
{
read(Wa_num[i][j]);
solve_time[i][cnt[i]++] = done_Time[i][j];
pen_time[i] += done_Time[i][j] + 20 * Wa_num[i][j];
maxx_solve_all = max(maxx_solve_all, done_Time[i][j]);
minn_solve_all = min(minn_solve_all, done_Time[i][j]);
minn_solve[j] = min(minn_solve[j], done_Time[i][j]);
}
}
sort(solve_time[i], solve_time[i] + cnt[i], lessthan);
other_rank[i] = i;
}
sort(other_rank + 1, other_rank + N, cmp);
for(int i=0; i<10; i++)
{
if(~read(need_time[i]))
{
read(need_wa[i]);
perm[cnt_N++] = i;
}
}
int ans = 0, tmp_ans, tim_now, rk;
do
{
tmp_ans = 0; tim_now = 0;
pen_time[N] = cnt[N] = 0;
for(int i=0; i<cnt_N; i++)
{
if(tim_now + need_time[perm[i]] > 300) break;
tim_now += need_time[perm[i]];
pen_time[N] += tim_now + need_wa[perm[i]] * 20;
solve_time[N][cnt[N]++] = tim_now;
if(tim_now <= minn_solve[perm[i]]) tmp_ans += 800;
if(!i && tim_now <= minn_solve_all) tmp_ans += 700;
}
if(cnt[N] && tim_now >= maxx_solve_all) tmp_ans += 500;
for(int i = 0, j = cnt[N] - 1; i < j; i++, j--) swap(solve_time[N][i], solve_time[N][j]);
rk = Get_Rank();
tmp_ans += 5000 / rk;
if(rk <= N / 10) tmp_ans += 1200;
else if(rk <= 3 * N / 10) tmp_ans += 800;
else if(rk <= 6 * N / 10) tmp_ans += 400;
ans = max(ans, tmp_ans);
} while(next_permutation(perm, perm + cnt_N));
printf("%d\n", ans);
return 0;
}