[Codeforces Round #673 (Div. 2) ]

题目链接#

A. Copy-paste

思路:

贪心的策略。每次只加上最小的就可以了

#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
typedef long long ll;
ll a[1010];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t;
cin>>t;
while(t--)
{
ll ans=0,n,k;
cin>>n>>k;
for(ll i=0; i<n; i++)
cin>>a[i];
sort(a,a+n);
for(ll i=1; i<n; i++)
{
ans+=(k-a[i])/a[0];
}
cout<<ans<<"\n";
}
return 0;
}

B. Two Arrays

思路:

晚上的思路是用hashmap来实现...但做着做着到了12点,做不下去了就耻辱得下机。。

看群里也有人在讨论这道题..各种想法的都有,结果大家都想多了。这不就是一道贪心题/doge

以\(T/2\)作为界限,小的涂白(1),大的涂黑(0)。边读入边做就行了。

《论审题的重要性》

#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
typedef long long ll;
const int max_n=1e5+5;
ll a[max_n];// c whilte d black
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t;
cin>>t;
while(t--)
{
memset(a,0,sizeof(a));
ll n,k,cnt=0,x;
cin>>n>>k;
for(ll i=0; i<n; i++)
{
cin>>x;
if (x*2==k)
a[i]=(cnt++)%2;
else if (x*2<k)
a[i]=1; }
for(ll i=0; i<n; i++)
cout<<a[i]<<' ';
cout<<"\n";
}
return 0;
}

下面的题目等div3结束抽空补了

Codeforces Round #673 (Div. 2)的更多相关文章

  1. Codeforces Round #673 (Div. 2) A. Copy-paste(贪心)

    题目链接:https://codeforces.com/contest/1417/problem/A 题意 给出一个大小为 $n$ 的数组 $a$,每次操作可以选择两个数,然后将一个数加到另一个数上, ...

  2. Codeforces Round #673 (Div. 2) B. Two Arrays(数学)

    题目链接:https://codeforces.com/contest/1417/problem/B 题意 定义 $f(a)$ 为数组 $a$ 中满足: $i < j$ $a_i + a_j = ...

  3. Codeforces Round #673 (Div. 2) C. k-Amazing Numbers(思维)

    题目链接:https://codeforces.com/contest/1417/problem/C 题意 给出一个大小为 $n$ 的数组 $a$,计算当 $k$ 从 $1$ 到 $n$ 取值时在所有 ...

  4. Codeforces Round #673 (Div. 2) D. Make Them Equal(数论/构造)

    题目链接:https://codeforces.com/contest/1417/problem/D 题意 给出一个大小为 $n$ 的正整数数组 $a$ ,每次操作如下: 选择 $i,j$ 和 $x$ ...

  5. Codeforces Round #673 (Div. 2) C. k-Amazing Numbers (DP,思维)

    题意:有一组数,分别用长度从\([1,n]\)的区间去取子数组,要求取到的所有子数组中必须有共同的数,如果满足条件数组共同的数中最小的数,否则输出\(-1\). 题解:我们先从后面确定每两个相同数之间 ...

  6. Codeforces Round #673 (Div. 2) B. Two Arrays (贪心)

    题意:给你一组数\(a\)和一个数\(T\),将这组数分为两组\(c\)和\(d\),定义\(f(x)\)为数组\(x\)中任意两个不同元素的和为\(T\)的个数,问为了使\(min(f(c)+f(d ...

  7. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

随机推荐

  1. Windows中使用PowerShell查看和卸载补丁

    查看:get-hotfix -id KB4470788 卸载:wusa /uninstall /kb:3045999 get-hotfix -id KB4470788 wusa /uninstall ...

  2. Promise 和async/await 的使用理解

    Promise 和async/await 的使用理解 1. new Promise时就会开始执行语句. new Promise(resolve => resolove('成功信息') )     ...

  3. webpack(从上篇博客中拿出来的)

    插件配置: emmet: vscode内置了这个,但是没有开启,要在设置里面"emmet.triggerExpansionOnTab": true, vscoed-icons插件: ...

  4. 专为seo新手准备的百度分享工具教程

    http://www.wocaoseo.com/thread-178-1-1.html 百度分享工具是目前seo站长最为常用的工具之一,主要用来让用户分享来提高网站的流量,同时他也有很多实际有效的方式 ...

  5. SEO外包好还是自己组建团队

    http://www.wocaoseo.com/thread-151-1-1.html       营络营销已成为企业不可忽视的一块大肥肉,很多企业都想进来分一杯羹,但是不少企业苦于缺少过硬的技术,无 ...

  6. css学习入门-第一个css程序

    1.css的优势: --内容与表现分离 --网页结构统一,可以实现复用 --样式丰富 2.css的3种导入方式 2.1行内样式 <h1 style="color: red"& ...

  7. mac下使用命令行安装、卸载ipa包、查看日志

    mac下使用命令行安装.卸载ipa包.查看日志 https://www.cnblogs.com/lily1989/p/8383916.html

  8. 有手就行 虚拟机上安装Linux

    VMware上装Linux CentOS 初学一步步来

  9. Stack (30)(模拟栈,输出中间数用set)

    Stack is one of the most fundamental data structures, which is based on the principle of Last In Fir ...

  10. 简单介绍HTML5 Landmark

    最近在进行无障碍相关文档翻译的时候遇到了 landmark 的概念,在网上搜了下发现没有相关的中文资料,因此写一篇博客简单介绍一下. 什么是 Landmark Landmark 是一种用来表示网页组织 ...