The 15th Zhejiang Provincial Collegiate Programming Contest(部分题解)
题意
给出n和n个数,判断该数列是否是凸形的。
解题思路
从前往后第一对逆序数,和从后往前第一队逆序数,如果都非零而且相邻,证明该数组是凸形的。
代码
#include <cstdio>
const int maxn = + ;
int a[maxn]; int main()
{
int T;
scanf("%d", &T);
while(T--) {
int n;
scanf("%d", &n);
for(int i = ; i < n; i++) {
scanf("%d", &a[i]);
}
int q = , h = , i;
for(i = ; i < n - ; i++) {
if(a[i] < a[i + ])
q++;
else
break;
}
for(; i < n - ; i++) {
if(a[i] > a[i + ])
h++;
else
break;
}
//printf("%d %d\n", q, h); if(q && h && q + h == n - )
puts("Yes");
else
puts("No");
}
return ;
}
题意
给出n,然后给出两个长度为n的序列S 和 D,问给每个D加上一个数k(可正,可负,可零),最大的耦合度是多少
解题思路
先用S减D得到每个差值的次数,然后找到差值次数最多的数即可。
代码
#include <cstdio>
#include <map> using namespace std;
const int maxn = + ;
int D[maxn], S[maxn];
int n; map<int, int> mp;
int main()
{
int T;
scanf("%d", &T);
while(T--) {
scanf("%d", &n);
for(int i = ; i < n; i++) {
scanf("%d", &D[i]);
}
for(int i = ; i < n; i++) {
scanf("%d", &S[i]);
} mp.clear();
for(int i = ; i < n; i++) {
mp[S[i] - D[i]]++;
}
int maxc = ;
map<int, int>::iterator it;
for(it = mp.begin(); it != mp.end(); it++) {
if((*it).second > maxc)
maxc = (*it).second;
}
printf("%d\n", maxc);
}
return ;
}
给出n和k,然后n个数,只要有一个数加上k能够将7整除,就是Yes。
#include <cstdio> int n, k;
int main()
{
int T;
scanf("%d", &T);
while(T--) {
scanf("%d%d", &n, &k);
int a, f = ;
for(int i = ; i < n; i++) {
scanf("%d", &a);
if((a + k) % == )
f = ;
}
if(f)
puts("Yes");
else
puts("No");
}
return ;
}
ZOJ 4035 Doki Doki Literature Club
给出n个单词列表和单词限制数m,然后每个单词的满足度,问组成m个最大满意度的单词列表。
排序,注意先按满意度排,再按照字典序排,另外可能超int范围。
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std;
const int wl = + ;
const int maxw = + ;
struct Word {
char w[wl];
int s;
bool operator < (const struct Word &a) const {
if(a.s == s) {
if(strcmp(a.w, w) > )
return ;
else
return ;
}
return a.s < s;
}
}wo[maxw]; int n, m;
int main()
{
int T;
scanf("%d", &T);
while(T--) {
scanf("%d%d", &n, &m);
for(int i = ; i <= n; i++) {
scanf("%s %d", wo[i].w, &wo[i].s);
} sort(wo + , wo + n + );
/*for(int i = 1; i <= n; i++) {
printf("%s %d\n", wo[i].w, wo[i].s);
}*/
long long sc = ;
for(int i = ; i <= m; i++) {
sc += (long long)(m - i + ) * wo[i].s;
}
printf("%lld",sc);
for(int i = ; i <= m; i++) {
printf(" %s", wo[i].w);
}
puts("");
}
return ;
}
The 15th Zhejiang Provincial Collegiate Programming Contest(部分题解)的更多相关文章
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club
Doki Doki Literature Club Time Limit: 1 Second Memory Limit: 65536 KB Doki Doki Literature Club ...
- 2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple
我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错 ...
- 【贪心】LIS @The 15th Zhejiang Provincial Collegiate Programming Contest E
传送门 题意要你构造一个序列,使得该序列的每个位置上的最长上升子序列的长度能构成给定的序列. 构造序列的元素要求还要求满足给定的上下界 solution 我们可以把给出的最长上升子序列的长度按升序排列 ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - M Lucky 7
Lucky 7 Time Limit: 1 Second Memory Limit: 65536 KB BaoBao has just found a positive integer se ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - J CONTINUE...?
CONTINUE...? Time Limit: 1 Second Memory Limit: 65536 KB Special Judge DreamGrid has clas ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - B King of Karaoke
King of Karaoke Time Limit: 1 Second Memory Limit: 65536 KB It's Karaoke time! DreamGrid is per ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple -A Peak
Peak Time Limit: 1 Second Memory Limit: 65536 KB A sequence of integers is called a peak, if ...
- ZOJ 4033 CONTINUE...?(The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple)
#include <iostream> #include <algorithm> using namespace std; ; int a[maxn]; int main(){ ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
随机推荐
- linux (ubuntu) 命令学习笔记
1, md5sum 输出字符串的MD5值 echo -n 123456 | md5sum //-n表示不打印回车符 2, ubuntu设置dock任务栏鼠标点击效果 16.04: 调整位置:gsett ...
- vim配置文件.vimrc
20171127备份 syntax on "自动语法高亮 set number "显示行号 set autoindent "回车后自动缩进 set tabstop=4 & ...
- 下划线“_”在oracle中不是单纯的表示下划线的意思,而是表示匹配单一任何字符!
[解决办法]1.使用 escape() 函数escape关键字经常用于使某些特殊字符,如通配符:'%','_'转义为它们原来的字符的意义,被定义的转义字符通常使用'\',但是也可以使用其他的符号.例如 ...
- POM文件详解(1)
POM文件详解 <project xmlns=http://maven.apache.org/POM/4.0.0 xmlns:xsi="http://www.w3.org/2001/X ...
- Memcached未授权访问
概念 memcached是一个内存中的键值存储区,用于存储来自数据库调用.API调用或页面呈现结果的任意小数据块(字符串.对象).memcached简单但功能强大.其简单的设计促进了快速部署.易于开发 ...
- angular-指令
ng-app 作用域 ng-init 声明 module 模块 ng-model 双向绑定 ng-bind 绑定 angular是一个MVC框架:即 M------------------module ...
- submit插件安装的问题与集成了插件的submit
写在最前面,方法有二种.一种是在线安装,这种办法我尝试过,受网速和软件卡顿的问题,进行不顺利.第二种就是我下面介绍的这种,手动安装. 最精华的在后面,可以直接跳转到最后.我找了很久的,最新版的汉化,而 ...
- Must Know Tips/Tricks in Deep Neural Networks
Must Know Tips/Tricks in Deep Neural Networks (by Xiu-Shen Wei) Deep Neural Networks, especially C ...
- pip 安装模块时出现error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools":
在使用pip安装mysqlclient模块时,出现如下错误: 在网上查找资料后显示可能是由于不兼容导致的,最好去下载.whl文件安装成功. 资源地址:http://www.lfd.uci.edu/~g ...
- Docker学习笔记-简单运行.netcore
前言: 环境:centos7.5 64 位 正文: 拉取 microsoft/dotnet, 安装完毕后执行 docker images 可以看到本地已经包含 microsoft/dotnet #包含 ...