【BZOJ3709】【PA2014】Bohater
2018-03-22 13:38
253 查看
【题目链接】
点击打开链接
【思路要点】
补档博客,无题解。
【代码】
点击打开链接
【思路要点】
补档博客,无题解。
【代码】
#include<bits/stdc++.h> using namespace std; #define MAXN 100005 struct info {long long cost, value; int home; }; int n, sa, sb, ans[MAXN], point; info a[MAXN], b[MAXN]; long long sx, sy, value, tmp; bool cmp (info x, info y) { return x.cost < y.cost; } bool fail() { sort(a + 1, a + sa + 1, cmp); for (int i = 1; i <= sa; i++) { ans[i] = a[i].home; if (a[i].cost >= value) return true; value += a[i].value - a[i].cost; } point = n; value = tmp; sort(b + 1, b + sb + 1, cmp); for (int i = 1; i <= sb; i++) { ans[point--] = b[i].home; if (b[i].cost >= value) return true; value += b[i].value - b[i].cost; } printf("TAK\n"); for (int i = 1; i <= n; i++) printf("%d ", ans[i]); printf("\n"); return false; } int main() { scanf("%d%lld", &n, &value); for (int i = 1; i <= n; i++) { long long x, y; scanf("%lld%lld", &x, &y); sx += x; sy += y; if (x <= y) a[++sa] = (info) {x, y, i}; else b[++sb] = (info) {y, x, i}; } if (sx > sy + value) { printf("NIE\n"); return 0; } tmp = sy + value - sx; if (fail()) printf("NIE\n"); return 0; }
相关文章推荐
- 【PA2014】【BZOJ3709】Bohater
- bzoj3709 [PA2014]Bohater
- [bzoj3709] [PA2014]Bohater
- bzoj3709 [PA2014]Bohater
- bzoj 3709: [PA2014]Bohater
- bzoj3709 [PA2014]Bohater
- bzoj3709 [PA2014]Bohater
- BZOJ3709 [PA2014]Bohater
- 【贪心】bzoj 3709:[PA2014]Bohater
- BZOJ 3709: [PA2014]Bohater
- BZOJ 3709: [PA2014]Bohater
- bzoj 3709: [PA2014]Bohater
- BZOJ3709: [PA2014]Bohater
- 【贪心】bzoj3709 [PA2014]Bohater
- 【BZOJ4619/3709】[Wf2016]Swap Space/[PA2014]Bohater 贪心
- BZOJ 3709: [PA2014]Bohater 贪心
- 【bzoj3709】[PA2014]Bohater
- 【贪心】bzoj 3709:[PA2014]Bohater
- BZOJ3709 [PA2014]Bohater
- bzoj 3709: [PA2014]Bohater 贪心