codeforces 798 D. Mike and distribution 二维贪心
来源:互联网 发布:淘宝皇冠买家号出售 编辑:程序博客网 时间:2024/05/29 14:57
题目传送门
另外种想法。用随机数。总会随机到满足条件的嘛 23333
#include <bits/stdc++.h>//#include <ext/pb_ds/tree_policy.hpp>//#include <ext/pb_ds/assoc_container.hpp>//using namespace __gnu_pbds;using namespace std;#define pi acos(-1)#define endl '\n'#define me(x) memset(x,0,sizeof(x));#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)#define close() ios::sync_with_stdio(0);#define rand() srand(time(0));typedef long long LL;const int INF=0x3f3f3f3f;const LL LINF=0x3f3f3f3f3f3f3f3fLL;//const int dx[]={-1,0,1,0,-1,-1,1,1};//const int dy[]={0,1,0,-1,1,-1,1,-1};const int maxn=1e3+5;const int maxx=1e5+100;const double EPS=1e-9;const int MOD=1000000007;#define mod(x) ((x)%MOD);template<class T>inline T min(T a,T b,T c) { return min(min(a,b),c);}template<class T>inline T max(T a,T b,T c) { return max(max(a,b),c);}template<class T>inline T min(T a,T b,T c,T d) { return min(min(a,b),min(c,d));}template<class T>inline T max(T a,T b,T c,T d) { return max(max(a,b),max(c,d));}//typedef tree<pt,null_type,less< pt >,rb_tree_tag,tree_order_statistics_node_update> rbtree;/*lch[root] = build(L1,p-1,L2+1,L2+cnt); rch[root] = build(p+1,R1,L2+cnt+1,R2);中前*//*lch[root] = build(L1,p-1,L2,L2+cnt-1); rch[root] = build(p+1,R1,L2+cnt,R2-1);中后*/long long gcd(long long a , long long b){if(b==0) return a;a%=b;return gcd(b,a);}int a[maxx],b[maxx],c[maxx];int main(){ rand(); int n; cin>>n; LL sum1=0,sum2=0; for(int i = 1 ; i <= n ; i++) { cin>>a[i]; c[i]=i; sum1+=a[i]; } for(int i = 1 ; i <= n ; i++) { cin>>b[i]; sum2+=b[i]; } int k=n/2+1; cout<<k<<endl; for(;;) { random_shuffle(c+1,c+n+1); LL fa=0,fb=0; for(int i=1;i<=k;i++) { fa+=a[c[i]]; fb+=b[c[i]]; } if(2*fa>sum1&&2*fb>sum2) { for(int i=1;i<=k;i++) printf("%d ",c[i]); return 0; } }}
0 0
- Codeforces 798D Mike and distribution(二维贪心)
- codeforces 798 D. Mike and distribution 二维贪心
- CodeForces 798D Mike and distribution(二维贪心 + 思维)
- Codeforces-798D-Mike and distribution(贪心)
- Codeforces 798D Mike and distribution 构造
- codeforces 798D Mike and distribution
- codeforces 798D Mike and distribution
- CodeForces 798D Mike and distribution
- Codeforces-798D. Mike and distribution
- Codeforces Round #410 (Div. 2) D. Mike and distribution(贪心)
- 798D Mike and distribution
- Codeforces 798D Mike and distribution (构造 + 脑洞 推荐)
- Codeforces 798D Mike and distribution【思维+贪心】好题!好题!感觉智商受到了一万点伤害= =
- D. Mike and distribution
- CF-Codeforces Round #410 (Div. 2)-D-Mike and distribution
- Codeforces Round #410 (Div. 2) D. Mike and distribution 思维
- Codeforces Round #410 Div2 D Mike and distribution
- Codeforces 798C Mike and gcd problem gcd+贪心
- 十种排序算法总结(冒泡、插入、选择、希尔、归并、堆、快速,计数,桶,基数)
- webstorm支持es6与vue文件高亮
- 丑数。。。vector赋予空间,min函数
- 黑马程序员 十三、GUI
- 《探索C++多线程》:condition_variable源码(二)
- codeforces 798 D. Mike and distribution 二维贪心
- 冬日初雪
- 黑马程序员 十四、Eclipse 的使用、增强 for 循环、自动拆箱与装箱等
- 几款免费wordpress主题推荐
- 网站常用的五种布局方案
- Qt设置中文乱码问题
- 关于网站做多语言切换功能的最简单实现思路
- 文章标题
- python opencv人脸检测提取及保存