2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 几道简单题的题解
A. Toda 2
题意:给你n个人,每个人的分数是a[i],每次可以从两个人到五个人的使得分数减一,使得最终的分数相等;
思路:假设答案为m;每个人的分数与答案m的差值为d[i],sum为d[i]的总和,max为d[i]的最大值;仅当sum-max>=max的时候才满足;
满足之后,总和为奇数,先取三个,再取两个(都是最大与次大值);偶数每次取两个即可;
B. Minimum and Maximum
题意:人机交互题;给你一个数组 ,找出其中的最小值与最大值,需要在询问f(n)的次数内得到最大值与最小值;
每次询问,? i j表示i和j的下标,告诉你哪个大,相等或者小,得到答案;
思路:类似与归并排序的思想,每次取两个,得到最大最小值;
G. Car Repair Shop
题意:给你n个区间,起点和长度;当当前区间与前面的区间有交集的时候,找到另外一个相同长度的区间放进去;
思路:模拟,先有一个大区间,每次插入一个区间,把这个区间修改成空白点的,把那个大区间拆成两个小区间,如果原来的区间内有空白,从1开始查找是否有长度
大于当前长度的区间,放入;
set模拟;
H. Delete Them
队友写的;
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define ls i<<1
#define rs ls | 1
#define mid ((ll+rr)>>1)
#define pii pair<int,int>
#define MP make_pair
typedef long long LL;
const long long INF = 1e18+1LL;
const double Pi = acos(-1.0);
const int N = 1e3+, M = 2e5+, mod = 1e9+, inf = 2e9; int a[N],n,m,pos[N],H[N];
char s[N][N];
set<int > S;
int main() {
scanf("%d%d",&n,&m);
for(int i = ; i <= n; ++i) scanf("%s",s[i]); for(int i = ; i <= m; ++i) scanf("%d",&pos[i]),H[pos[i]]=;
sort(pos+,pos+m+);
for(int i = ; i <= m; ++i) S.insert(strlen(s[pos[i]])); if(S.size() > ) {
puts("No");
return ;
} for(int i = ; i <= m; ++i) {
for(int j=;j<strlen(s[pos[i]]); ++j) {
if(s[pos[]][j]!=s[pos[i]][j]) {
s[pos[]][j] = '?';
}
}
}
for(int i = ;i<=n; ++i) if(!H[i]) {
int len = strlen(s[i]);
int sum = ;
if(len!=strlen(s[pos[]])) continue;
for(int j = ; j < len; ++j) {
if(s[pos[]][j] == '?') sum++;
else if(s[pos[]][j] == s[i][j]) sum++;
}
if(sum == len) {
puts("No");
return ;
} }
puts("Yes");
printf("%s\n",s[pos[]]);
}
J. Bottles
题意:给你n个瓶子,第一行a[i]表示第i个瓶子的剩余水的容量,第二行b[i]表示第i个瓶子的体积;
你需要使用最少的瓶子数量,装完剩下全部的水,每次改变n单位的水的花费n;
思路:k很好求,贪心求法,开始以为n就100,写个暴搜+剪枝,TLE TEST 42;
后面发现就一个背包,只是这个背包需要求的是恰好装满这个背包大小的最大价值;
剩余水的质量为sum1,瓶子的体积和sum2;你需要找到sum1-sum2之间的最大值;
dp[k][sum1]-dp[k][sum2];
复杂度(k*sum2*n);
优化下可以(k*sum1*n);
2 seconds
512 megabytes
standard input
standard output
Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volumebi (ai ≤ bi).
Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends xseconds to pour x units of soda from one bottle to another.
Nick asks you to help him to determine k — the minimal number of bottles to store all remaining soda and t — the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved.
The first line contains positive integer n (1 ≤ n ≤ 100) — the number of bottles.
The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 100), where ai is the amount of soda remaining in the i-th bottle.
The third line contains n positive integers b1, b2, ..., bn (1 ≤ bi ≤ 100), where bi is the volume of the i-th bottle.
It is guaranteed that ai ≤ bi for any i.
The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles.
4
3 3 4 3
4 7 6 5
2 6
2
1 1
100 100
1 1
5
10 30 5 6 24
10 41 7 8 24
3 11
In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6seconds to do it.
2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 几道简单题的题解的更多相关文章
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution
从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...
- Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结
第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...
- codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解
秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
A. Find a Number 找到一个树,可以被d整除,且数字和为s 记忆化搜索 static class S{ int mod,s; String str; public S(int mod, ...
- 2018.10.20 2018-2019 ICPC,NEERC,Southern Subregional Contest(Online Mirror, ACM-ICPC Rules)
i207M的“怕不是一个小时就要弃疗的flag”并没有生效,这次居然写到了最后,好评=.= 然而可能是退役前和i207M的最后一场比赛了TAT 不过打得真的好爽啊QAQ 最终结果: 看见那几个罚时没, ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) Solution
A. Find a Number Solved By 2017212212083 题意:$找一个最小的n使得n % d == 0 并且 n 的每一位数字加起来之和为s$ 思路: 定义一个二元组$< ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror) in codeforces(codeforces730)
A.Toda 2 思路:可以有二分来得到最后的数值,然后每次排序去掉最大的两个,或者3个(奇数时). /************************************************ ...
随机推荐
- linux之V4L2摄像头应用流程【转】
本文转载自:http://blog.csdn.net/tommy_wxie/article/details/11486907 对于v4l2,上次是在调试收音机驱动的时候用过,其他也就只是用i2c配置一 ...
- 使用BusyBox制作根文件系统【转】
本文转载自:http://www.cnblogs.com/lidabo/p/5300180.html 1.BusyBox简介 BusyBox 是很多标准 Linux 工具的一个单个可执行实现.Busy ...
- Apache服务器访问过慢分析及解决
起因:线上的一台服务器,最近总是出现 访问 很慢的情况发生,点击一个链接要2秒钟以上才能打开,按照我们对于访问人数的估计,服务器应该不至于响应这么慢,从而需要针对这个问题进行分析,来解决网站访问过慢. ...
- Web API 和 WCF 的比较
现在有很多可用的技术允许你创建被不同客户端所消费的服务,这些客户端可能是Web应用程序.Windows应用程序和移动应用等.服务可以支持http协议或者其他协议.接下来的讨论仅限于ASP.NET We ...
- [转]Windows配置Git
原文地址:http://blog.csdn.net/exlsunshine/article/details/18939329 1.从git官网下载windows版本的git:http://git-sc ...
- [转]JEXUS的高级配置
转自:http://www.cnblogs.com/xiaodiejinghong/archive/2013/04/14/3019660.html 前一回合,我们对服务器软件Jexus作了简单的介绍, ...
- 【Pro ASP.NET MVC 3 Framework】.学习笔记.12.ASP.NET MVC3的细节:URLs,Routing和Areas
Adam Applied ASP.NET 4 in Context 1 介绍Routing系统 在引入MVC之前,ASP.NET假定被请求的URLs和服务器硬盘上的文件之间有着直接关系.服务器的任务是 ...
- 在centos6.5上面mount微软系统上安装ftp服务器
---恢复内容开始--- 现在用虚拟机开发linux软件,发现虚拟机提供的共享文件夹不能很好地工作,表现为: 1.我在windows上面修改了文件内容,在linux里面发现文件内容没有变化,需要做些等 ...
- HLS视频直播
HTTP Live Streaming (HLS) 苹果官方对于视频直播服务提出了 HLS 解决方案,该方案主要适用范围在于: 使用 iPhone .iPod touch. iPad 以及 Apple ...
- 常用的math函数
<?php //1.abs — 绝对值 echo abs(-77); //ceil — 进一法取整 ...