D. Mike and distribution 首先学习了一个玄学的东西
2017-04-22 23:45
393 查看
http://codeforces.com/contest/798/problem/D
D. Mike and distribution
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integersA = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk)is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to
View Code
2017-4-23 22:22:03
要开始补sg函数(博弈)和构造题。先复习下字符串准备省赛。
D. Mike and distribution
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integersA = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.
To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk)is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <assert.h> #define IOS ios::sync_with_stdio(false) using namespace std; #define inf (0x3f3f3f3f) typedef long long int LL; #include <iostream> #include <sstream> #include <vector> #include <set> #include <map> #include <queue> #include <string> #include <bitset> const int maxn = 1e5 + 20; struct Node { int a, id; bool operator < (const struct Node & rhs) const { return a > rhs.a; } }a[maxn]; int b[maxn]; vector<int>ans; void work() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i].a; a[i].id = i; } for (int i = 1; i <= n; ++i) { cin >> b[i]; } sort(a + 1, a + 1 + n); int sel = n / 2 + 1; ans.push_back(a[1].id); for (int i = 2; i <= n; i += 2) { int want = a[i].id; if (i + 1 <= n && b[want] < b[a[i + 1].id]) { want = a[i + 1].id; } ans.push_back(want); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); ++i) { cout << ans[i] << " "; } } int main() { #ifdef local freopen("data.txt", "r", stdin); // freopen("data.txt", "w", stdout); #endif IOS; work(); return 0; }
View Code
2017-4-23 22:22:03
要开始补sg函数(博弈)和构造题。先复习下字符串准备省赛。
相关文章推荐
- 一个程序员该学习的东西
- FFMPEG理解一个偶然遇到了ffmpeg,看起来不多,而且通用性很强,算是一个扎实的技术。 研究了两天了,万事开头难啊。 主要是新手学习一个东西的时候,没有宏观的概念,如果猛地往某个细节去钻,往往碰
- 推荐一个WSS学习的好网站:http://wss.collutions.com and Http://www.wssdemo.com,本人决没有做广告的意思,只是觉得上面的东西不错。
- 6、用vb6写一个仿照SPY++的东西,供大家参考学习用
- 记不住东西首先是因为你犯了一个毛病
- 谈下最近做的一个手机app,学习到的东西挺多的哦
- 零基础入门学习Python(30)--文件系统:介绍一个高大上的东西
- 从技术到做管理,角色的转变首先是一个学习的过程,其次是一个潜移默化、循序渐进的实践过程
- [每周翻译]作为一个计算鸡领域相关的学生狗,有毛东西可以让我花10分钟学习然后享受一生的?
- 谈谈深度学习中的 Batch_Size Batch_Size(批尺寸)是机器学习中一个重要参数,涉及诸多矛盾,下面逐一展开。 首先,为什么需要有 Batch_Size 这个参数? Batch 的选
- 认识一个东西用感性,学习一个东西用理性!
- Hadoop学习笔记—4.初识MapReduce 一、神马是高大上的MapReduce MapReduce是Google的一项重要技术,它首先是一个编程模型,用以进行大数据量的计算。对于大数据
- 如何学习一个新东西
- 文件系统:介绍一个高大上的东西 - 零基础入门学习Python030
- 学习笔记-小甲鱼Python3学习第三十讲:文件系统:介绍一个高大上的东西
- 由一个自定义的MapReduce程序报错学习到的东西
- 推荐一个学习新技术的方法
- 要学的东西太多,必须选一个方向
- 在学习使用delphi进行网络时,书上忽略的一点东西
- 如何在POSTS编辑器中添加一个按钮,用来插入新的东西。