题目链接

A. Elimination

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.

The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination.

As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible.

Input

The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners.

Output

In the first line, print a single integer — the minimum number of problems the jury needs to prepare.

Sample test(s)
input
1 10
7 2
1
output
2
input
2 2
2 1
2
output

0

题意 :淘汰赛分为主赛和附加赛,主赛一轮有c道题,附加赛一轮有d道题,主赛每轮可以选拔出n个人,附加赛每次可以选出1个人,还有k个人不用参加淘汰赛,要求最后要选出m×n个人主办方需要准备的最少的题目是多少。

思路 : 一开始没明白题目是什么意思。要求最少的题目数,就先判断一下要用主赛还是附加赛,判断一下题目数。
 #include <stdio.h>
#include <string.h>
#include <iostream> using namespace std ; int main()
{
int c,d ;
int n,m ;
int k ;
while(~scanf("%d %d",&c,&d))
{
scanf("%d %d %d",&n,&m,&k) ;
if(n * m - k <= )
{
printf("0\n") ;
continue ;
}
int a = n*m-k ;
int ans = ;
if(c < d*n)
{
int x = a / n ;
ans += x*c ;
int y = a % n ;
ans += min(c,d*y) ;
}
else
ans = a * d ;
printf("%d\n",ans) ;
}
return ;
}

B. Crash

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.

Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.

It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.

During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.

Input

The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.

Output

A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.

Sample test(s)
input
2
0 1
1 1
output
YES
input
4
0 1
1 2
1 1
0 2
output
NO
input
4
0 1
1 1
0 1
0 2
output

YES

题意 :每一个上交的答案都有两个标志,x和k,代表k这个人交的第x个不一样的答案,然后给你n个x和k,问你是不是按照时间排得序,而这个按照时间排序的要求就是对于每一个大于0的x,都要求在前边出现过同一个人交过的x-1.否则输出NO

思路 : 拿一个数组标记一下。
 #include <stdio.h>
#include <string.h>
#include <iostream> using namespace std ; int a[] ;
int main()
{
int n,x,k ;
while(~scanf("%d",&n))
{
bool flag = false ;
memset(a,-,sizeof(a)) ;
for(int i = ; i <= n ; i++)
{
scanf("%d %d",&x,&k) ;
if(a[k] == x-)
a[k]++ ;
else if(a[k] < x-)
flag = true ;
}
if(flag) printf("NO\n") ;
else printf("YES\n") ;
}
return ;
}

C. Football

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided inton teams and played several matches, two teams could not play against each other more than once.

The appointed Judge was the most experienced member — Pavel. But since he was the wisest of all, he soon got bored of the game and fell asleep. Waking up, he discovered that the tournament is over and the teams want to know the results of all the matches.

Pavel didn't want anyone to discover about him sleeping and not keeping an eye on the results, so he decided to recover the results of all games. To do this, he asked all the teams and learned that the real winner was friendship, that is, each team beat the other teams exactly k times. Help Pavel come up with chronology of the tournir that meets all the conditions, or otherwise report that there is no such table.

Input

The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).

Output

In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ nai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won against the team with number bi. You can assume, that the teams are numbered from1 to n.

If a tournir that meets the conditions of the problem does not exist, then print -1.

Sample test(s)
input
3 1
output

3
1 2
2 3
3 1

题意 :就是n个队,每个队都刚好赢了其他队k次,当然,人两个队打比赛都不能超过两次。输出两个队的对号,前者赢了后者。

思路 : 先判断一下够不够赢其他队的,然后再从头开始输出就行。
 #include <iostream>
#include <stdio.h>
#include <string.h> using namespace std; int main()
{
int n ,k;
while(scanf("%d %d",&n,&k) != EOF)
{
if(k* >= n)
{
printf("-1\n") ;
continue ;
}
printf("%d\n",n*k) ;
for(int i = ; i <= n ; i++)
for(int j = i+ ; j <= i+k ; j++)
printf("%d %d\n",i,(j-) % n+) ;
}
return ;
}

RCC 2014 Warmup (Div. 2) ABC的更多相关文章

  1. RCC 2014 Warmup (Div. 2)

    一场很很多HACK的比赛,PREtest太弱了,真的很多坑!平时练习的时候很少注意这些东西了! A:开始一直在模拟,后来发现自己的思路逻辑很乱,果然做比赛不给力! 直接在代码中解释了 #include ...

  2. RCC 2014 Warmup (Div. 2) A~C

    近期CF的pretext真是一场比一场弱.第一次在CF上被卡cin.cout.... A. Elimination time limit per test 1 second memory limit ...

  3. RCC 2014 Warmup (Div. 1)

    A 暴力 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm& ...

  4. RCC 2014 Warmup (Div. 2) 蛋疼解题总结

    A. Elimination time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  5. 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 ...

  6. Codeforces Round #247 (Div. 2) ABC

    Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431  代码均已投放:https://github.com/illuz/Wa ...

  7. Codeforces Round #312 (Div. 2) ABC题解

    [比赛链接]click here~~ A. Lala Land and Apple Trees: [题意]: AMR住在拉拉土地. 拉拉土地是一个很漂亮的国家,位于坐标线.拉拉土地是与著名的苹果树越来 ...

  8. Codeforces Round #419 (Div. 2) ABC

    python 2.7,用来熟悉Python 由于都是智障题,所以我也不讲述题意和题解,直接贴代码了-- A import sys h,m = map(int,raw_input().split(&qu ...

  9. Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2)---ABC

    A---The King's Race http://codeforces.com/contest/1075/problem/A 题意: 一个人在\((1,1)\), 一个人在\((n,n)\), 现 ...

随机推荐

  1. Spring使用总结

    一.基础JAR包 spring-beans.jar spring-context.jar spring-core.jar spring-expression.jar 二.XML的配置 1.一级结构 & ...

  2. AngularJS 的那些内置九种过滤器

    ng内置了九种过滤 1. currency (货币处理) 使用currency可以将数字格式化为货币,默认是美元符号,你可以自己传入所需的符号,例如我传入人民币: {{num | currency : ...

  3. 【转载】应广大群众的要求,今天开始连载《超容易的Linux系统管理入门书》一书

    学习Linux容易嘛?我说超容易,你肯定不信.那学习Linux最好的学习方法是什么,就是脑子里面一直提问题,不停的提,时时刻刻提,如果你没有问题,那再容易的学习书你也看不懂. <超容易的Linu ...

  4. dorado listener属性

    每一个控件都有一个listener属性,可以用来定位一个服务定位表达式,通过这个表达式, 它最终可以映射为spring里面一个javaBean的一个java方法 例如设置DynaView1.view. ...

  5. Windows内存原理与内存管理

    WIndows为每个进程分配了4GB的虚拟地址空间,让每个进程都认为自己拥有4GB的内存空间,4GB怎么来的? 32位 CPU可以取地址的空间为2的32次方,就是4GB(正如16位CPU有20根寻址线 ...

  6. shopnc 商城源码阅读笔记--开篇概述

    关于shopnc 以下是摘抄自百度百科的关于shopnc的介绍: ShopNC商城系统,是天津市网城天创科技有限责任公司开发的一套多店模式的商城系统. 本系统具有商城系统非常完整和专业的功能与流程,系 ...

  7. tortoiseGit的SHH秘钥设置

    tortoiseGit如果安装时使用默认的putty方式,因为putty的秘钥格式和SSH的不一样,所以要使用自带的工具重新生成一次秘钥. 具体的方式是:用puttyGen工具来生成公钥和秘钥,公钥( ...

  8. sqlsever2008及以上各个安装包的说明

    LocalDB (SqlLocalDB)LocalDB 是 Express 的一种轻型版本,该版本具备所有可编程性功能,但在用户模式下运行,并且具有快速的零配置安装和必备组件要求较少的特点.如果您需要 ...

  9. 升级python版本导致Django无法使用的解决办法

    运行环境是CentOS6.2 x86_64,在把python从2.6.6升级到2.7.5后,由于环境变量的改变,在python代码中再import django的话将会出现以下报错:   “No mo ...

  10. 自动化运维——一键安装MySQL

    根据项目需要,前段时间在搞EMM系统各种安装包的自动化部署工作,主要包括一键安装和一键启动\停止功能.总结记录下来,以供后用. 本文主要是自动安装MySQL5.7.11版,Linux版脚本在CentO ...