近期CF的pretext真是一场比一场弱。第一次在CF上被卡cin。cout。。。。

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, kwinners 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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; int c,d,n,m,k,s; int main()
{
cin>>c>>d>>n>>m>>k;
s=n*m-k;
if(s<=0)
{
puts("0"); return 0;
}
int ans=0;
if(c<d*n)
{
int num_ma=s/n;
ans+=num_ma*c;
int resman=s%n;
ans+=min(resman*d,c);
}
else
{
ans=s*d;
}
cout<<ans<<endl;
return 0;
}

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

排序乱搞。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; struct ooxx
{
int x,y,id;
}a[110000]; bool cmpA(ooxx a,ooxx b)
{
if(a.y!=b.y) return a.y<b.y;
return a.id<b.id;
} int n; int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
a[i].id=i;
}
sort(a,a+n,cmpA); bool flag=true;
int last=-1,eb=-1; for(int i=0;i<n&&flag;i++)
{
if(last!=a[i].y)
{
last=a[i].y; eb=0;
if(a[i].x!=0) flag=false;
}
else
{
if(a[i].x<=eb) continue;
else if(a[i].x==eb+1) eb++;
else flag=false;
}
}
if(flag==false) puts("NO");
else puts("YES");
return 0;
}

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

隔k个数,连一条边。。。。 输出非常多,卡CIN,COUT

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector> using namespace std; typedef pair<int,int> pII; int indegree[2000];
bool ck[1100][1100];
int n,k;
vector<pII> ans; int main()
{
cin>>n>>k;
for(int l=1;l<=k;l++)
{
for(int i=0;i<n;i++)
{
int j=(i+l)%n;
if(indegree[j]+1>k||j==i||ck[i][j]||ck[j][i])
{
puts("-1"); return 0;
}
else
{
indegree[j]++;
ck[i][j]=ck[j][i]=1;
ans.push_back(make_pair(i,j));
}
}
}
int sz=ans.size();
printf("%d\n",sz);
for(int i=0;i<sz;i++)
{
printf("%d %d\n",ans[i].first+1,ans[i].second+1);
}
return 0;
}

RCC 2014 Warmup (Div. 2) A~C的更多相关文章

  1. RCC 2014 Warmup (Div. 2)

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

  2. RCC 2014 Warmup (Div. 2) ABC

    题目链接 A. Elimination time limit per test:1 secondmemory limit per test:256 megabytesinput:standard in ...

  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 - 417E(随机数)

    Square Table Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  6. CodeForces - 417B (思维题)

    Crash Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status ...

  7. CodeForces - 417A(思维题)

    Elimination Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit  ...

  8. Codeforces 417 C

    Football Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  9. CodeForces比赛总结表

    Codeforces A                     B                        C                             D            ...

随机推荐

  1. [BZOJ4861][BJOI2017]魔法咒语(AC自动机+矩阵优化DP)

    4861: [Beijing2017]魔法咒语 Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 217  Solved: 105[Submit][Sta ...

  2. 【最短路】NOIP模拟赛 虫洞

    虫洞 [题目描述] N个虫洞,M条单向跃迁路径.从一个虫洞沿跃迁路径到另一个虫洞需要消耗一定量的燃料和1单位时间.虫洞有白洞和黑洞之分.设一条跃迁路径两端的虫洞质量差为delta. 1. 从白洞跃迁到 ...

  3. 【计算几何】【分类讨论】Gym - 101173C - Convex Contour

    注意等边三角形的上顶点是卡不到边界上的. 于是整个凸包分成三部分:左边的连续的三角形.中间的.右边的连续的三角形. 套个计算几何板子求个三角形顶点到圆的切线.三角形顶点到正方形左上角距离啥的就行了,分 ...

  4. 【rope】bzoj1269 [AHOI2006]文本编辑器editor

    维护一个字符串,支持以下操作:   主要就是 成段插入.成段删除.成段翻转.前两个操作很好通过rope实现.第三个操作也不难,维护两个rope,一个正向,一个反向,翻转时swap一下就行了.   ro ...

  5. MySQL中变量的定义和变量的赋值使用(转)

    说明:现在市面上定义变量的教程和书籍基本都放在存储过程上说明,但是存储过程上变量只能作用于begin...end块中,而普通的变量定义和使用都说的比较少,针对此类问题只能在官方文档中才能找到讲解. 前 ...

  6. 1.4(SQL学习笔记)分组、子查询、联结、组合查询

    一.分组 建表及数据填充语句下载:链接: https://pan.baidu.com/s/1WHYafwqKJEKq1kDwCH_Zlg 提取码: 3wy4 1.1初识分组 分组是按照某一列,将该列中 ...

  7. 求图的强连通分量--tarjan算法

    一:tarjan算法详解 ◦思想: ◦ ◦做一遍DFS,用dfn[i]表示编号为i的节点在DFS过程中的访问序号(也可以叫做开始时间)用low[i]表示i节点DFS过程中i的下方节点所能到达的开始时间 ...

  8. linux安装Node(Centos)

    步骤 1.打开node官网,找到node版本的下载地址 这里我找到的地址是: https://npm.taobao.org/mirrors/node/v8.2.1/node-v8.2.1-linux- ...

  9. 【JSP JSTL】<c:if>多个判断条件 + <c:foreach>满足条件跳出循环

    有一个需求,将所拥有的权限存放于session中,现在JSP页面判断这些如果在所有权限中有某一个或者某几个,就显示相对应的页面内容 举一个例子,实现以上的逻辑,<c:if>多个判断条件 + ...

  10. Android内存优化13 内存泄漏常见情况4 资源泄漏

    资源未关闭或释放导致内存泄露 在使用IO.File流或者Sqlite.Cursor等资源时要及时关闭.这些资源在进行读写操作时通常都使用了缓冲,如果及时不关闭,这些缓冲对象就会一直被占用而得不到释放, ...