HDU 4393 Throw nails
来源:互联网 发布:java搭建项目的流程 编辑:程序博客网 时间:2024/05/19 01:32
因为第i个人第1秒走的距离Fi满足0 <= Fi <= 500,所以502秒后所有人的名次都不会再变化。所以,前502秒可以暴搜,剩下的只要排序后直接输出即可。
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <cmath>#include <vector>using namespace std;const int maxn = 50010;int t, n;struct Player { int k, s, id, dis;};Player p[maxn];bool cmp(Player p1, Player p2){ if (p1.k != p2.k) { return p1.k < p2.k; } if (p1.dis != p2.dis) { return p1.dis > p2.dis; } return p1.id < p2.id;}int main(){ scanf("%d", &t); for (int cas = 1; cas <= t; ++cas) { scanf("%d", &n); int f, s; p[0].dis = (1 << 30); p[0].k = -1; p[0].id = -1; for (int i = 1; i <= n; ++i) { scanf("%d%d", &f, &s); p[i].k = 1; p[i].s = s; p[i].id = i; p[i].dis = f; } printf("Case #%d:\n", cas); int Max = -1, idx; for (int i = 1; i <= n; ++i) { if (p[i].dis > Max) { Max = p[i].dis; idx = i; } } p[idx].k = -1; printf("%d", idx); for (int i = 2; i <= min(n, 502); ++i) { int Max = -1, idx; for (int j = 1; j <= n; ++j) { if (p[j].k == -1) continue; p[j].dis += p[j].s; if (p[j].dis > Max) { Max = p[j].dis; idx = j; } } p[idx].k = -1; printf(" %d", idx); } sort(p, p + n + 1, cmp); for (int i = 503; i <= max(502, n); ++i) { printf(" %d", p[i].id); } printf("\n"); } return 0;}
- hdu 4393 Throw nails
- hdu 4393 Throw nails
- HDU 4393 Throw nails
- hdu 4393 Throw nails
- HDU 4393 Throw nails
- HDU 4393 Throw nails
- HDU 4393 Throw nails (STL)
- HDU 4393 Throw nails(技巧性模拟)
- HDU 4393 Throw nails (暴力加排序)
- hdu 4393 Throw nails 相同的状态做相同的处理 贪心
- Throw nails hdu多校联赛10 1004 水题
- HDOJ 4393 Throw nails —— 思维题
- hdu4393 Throw nails【优先队列&&贪心&&模拟】
- HUD4393 Throw nails(思维模拟)
- hdu 4573 Throw the Stones
- hdu4393Throw nails
- throw
- throw()
- iPhone开发之UITableView入门2
- g++链接lib库时的顺序
- 如何安装appsync
- Android 八款开源 Android 游戏引擎 (巨好的资源)
- HDU 3339 In Action 解题报告(最短路+背包)
- HDU 4393 Throw nails
- 开始学习WEB技术
- 终于把 NGINX 端口问题解决啦
- POJ 2823 Sliding Window(单调队列)
- 动作暴露本性
- hdu 2767 Proving Equivalences (tarjan + 缩点)
- 安装WIN7时绕过自动产生100MB分区
- 和菜鸟一起学OK6410之tftp下载内核,nfs挂载文件系统全过程详解
- (一)核心组件详解