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 leastn·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

题意:为了进final举办淘汰赛,赛制有两种,一种是取前n个人晋级,需要用c个题目,另一种是取第一名需要c个题目,每次比赛都会特别邀请k个人,问选m*n个人最少

用多少题目。

sl: 没有更水的了,可惜开始没读懂题。对于最后余下的不足n的人数只要比较left*d和c的大小就好了, 其余的比较n*d和c的大小就好了。

1 #include<cstdio>

 2 #include<cstring>
 3 #include<algorithm>
 4 #include<vector>
 5 #include<queue>
 6 using namespace std;
 7 const int MAX = 1e3+;
 8 int main()
 9 {
     int c,d,n,m,k; int ans;
     while(scanf("%d %d",&c,&d)==)
     {
         ans=;
         scanf("%d %d",&n,&m); scanf("%d",&k);
         int tot=n*m-k;
         if(tot<=) printf("0\n");
         else
         {
             int x=tot/m; int cnt=tot/n; int cc=tot%n;
             if(n*d<=c) ans=n*cnt*d;
             else ans=c*cnt;
             if(cc*d<c) ans+=cc*d;
             else ans+=c;
             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

题意:就是给出每个人的编号和提交顺序,问是不是按时间顺序给出的(每个人的代码号都是从0开始递增的和别人无关)

sl:根据题意只要判断每个人的代码号书不是在前面出现过,没出现过的话直接判断是不是跟上一个数字连续就行。

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<vector>
 5 #include<queue>
 6 #include<set>
 7 using namespace std;
 8 const int MAX = 1e5+;
 9 vector<int> G[MAX];
 set<int> cnt[MAX];
 int main()
 {
     int n;    int x,k;
     while(scanf("%d",&n)==)
     {
         int flag=;
         for(int i=;i<n;i++)
         {
             scanf("%d %d",&x,&k);
             int m=G[k].size();
             if(!m)
             {
                 if(x==) G[k].push_back(x),cnt[k].insert(x);
                 else flag=,G[k].push_back(x),cnt[k].insert(x);
             }
             else if(cnt[k].count(x)) continue;
             else if(G[k][m-]==x-) G[k].push_back(x),cnt[k].insert(x);
             else flag=;
         }
         if(flag) printf("YES\n");
         else printf("NO\n");
     }
     return ;

34 }

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 into n 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 from 1 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场比赛并且每次只能和对手比一场,给出对战表。

sl:可以暴力过,也可以两个for循环过。(当时着急了直接暴力做的10min1Y)

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<vector>
 5 #include<queue>
 6 using namespace std;
 7 const int MAX = 1e3+;
 8 int vis[MAX][MAX],ans[MAX];
 9 vector<int> G[MAX];
 int main()
 {
     int n,k,tot;
     while(scanf("%d %d",&n,&k)==)
     {
         tot=;
         memset(vis,,sizeof(vis));
         memset(ans,,sizeof(ans));
         for(int i=;i<=n;i++)
         {
             for(int j=;j<=n;j++) if(i!=j)
             {
                 if(ans[i]==k) break;
                 if(!vis[i][j])
                 {
                     tot++;
                     vis[i][j]=vis[j][i]=;
                     ans[i]++;
                     G[i].push_back(j);
                 }
             }
         }
         int flag=;
         for(int i=;i<=n;i++) if(ans[i]!=k) flag=;
         if(!flag) printf("-1\n");
         else
         {
             printf("%d\n",tot);
             for(int i=;i<=n;i++) for(int j=;j<G[i].size();j++)
             printf("%d %d\n",i,G[i][j]);
         }
     }
     return ;

43 }

D. Cunning Gena
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him.

The participants are offered m problems on the contest. For each friend, Gena knows what problems he can solve. But Gena's friends won't agree to help Gena for nothing: the i-th friend asks Gena xi rubles for his help in solving all the problems he can. Also, the friend agreed to write a code for Gena only if Gena's computer is connected to at least ki monitors, each monitor costs b rubles.

Gena is careful with money, so he wants to spend as little money as possible to solve all the problems. Help Gena, tell him how to spend the smallest possible amount of money. Initially, there's no monitors connected to Gena's computer.

Input

The first line contains three integers nm and b (1 ≤ n ≤ 100; 1 ≤ m ≤ 20; 1 ≤ b ≤ 109) — the number of Gena's friends, the number of problems and the cost of a single monitor.

The following 2n lines describe the friends. Lines number 2i and (2i + 1) contain the information about the i-th friend. The 2i-th line contains three integers xiki and mi (1 ≤ xi ≤ 109; 1 ≤ ki ≤ 109; 1 ≤ mi ≤ m) — the desired amount of money, monitors and the number of problems the friend can solve. The (2i + 1)-th line contains mi distinct positive integers — the numbers of problems that the i-th friend can solve. The problems are numbered from 1 to m.

Output

Print the minimum amount of money Gena needs to spend to solve all the problems. Or print -1, if this cannot be achieved.

Sample test(s)
input
2 2 1
100 1 1
2
100 2 1
1
output
202
input
3 2 5
100 1 1
1
100 1 1
2
200 1 2
1 2
output
205
input
1 2 1
1 1 1
1
output
-1

题意:有m个问题,同时有n个人每个人能解决mi个问题,雇佣这个人花xi元,并且这个人需要ki个显示器,每个显示器b元。问解决m个问题最少花费多少钱

sl:看上去有点想背包。可以把问题个数想成背包容量,就是一个0-1背包。需要按显示器的个需求排序,因为同样解决m个问题用的显示器越少越好么。

状态方程  dp[state|cover]=min(dp[state|cover],dp[state]+x);

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 typedef long long LL;
 6 const int MAX = <<;
 7 const LL inf = 1LL<<;
 8 struct P
 9 {
     int x,k,m;
     int cover;
     bool operator < (const P &rhs) const
     {
         return k<rhs.k;
     }
 } v[];
 LL dp[MAX];
 int main()
 {
     int n,m,b; int a;
     while(scanf("%d %d %d",&n,&m,&b)==)
     {
         for(int i=;i<n;i++)
         {
             scanf("%d %d %d",&v[i].x,&v[i].k,&v[i].m); v[i].cover=;
             for(int j=;j<v[i].m;j++)
             {
                 scanf("%d",&a); v[i].cover|=(<<(a-));
             }
         }
 
         sort(v,v+n);
         for(int j=;j<=(<<m)-;j++) dp[j]=inf;
         dp[]=;
 
         LL ans=inf;
         for(int i=;i<n;i++)
         {
             for(int j=((<<m)-);j>=;j--)
             {
                 dp[j|v[i].cover]=min(dp[j|v[i].cover],dp[j]+v[i].x);
             }
             if(dp[(<<m)-]!=inf)
             ans=min(ans,dp[(<<m)-]+(LL)v[i].k*(LL)b);
 
         }
         if(ans>=inf) printf("-1\n");
         else printf("%I64d\n",ans);
     }
     return ;

51 }

E. Square Table
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

While resting on the ship after the "Russian Code Cup" a boy named Misha invented an interesting game. He promised to give his quadrocopter to whoever will be the first one to make a rectangular table of size n × m, consisting of positive integers such that the sum of the squares of numbers for each row and each column was also a square.

Since checking the correctness of the table manually is difficult, Misha asks you to make each number in the table to not exceed 108.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 100)  — the size of the table.

Output

Print the table that meets the condition: n lines containing m integers, separated by spaces. If there are multiple possible answers, you are allowed to print anyone. It is guaranteed that there exists at least one correct answer.

Sample test(s)
input
1 1
output
1
input
1 2
output
3 4

题意:很鸟蛋的一体,就是给出矩阵的行列,叫你给出一个矩阵,满足每一行的平方和仍然是某一个数的平方。每一列的平方和仍然是某一个数的平方。

sl:数学构造了,看了下别人的题解都是千奇百怪的,都很神奇有一个是这么写的

先构造出一个一维的长度为n的序列在用同样的方法构造出长度为m的序列 然后用长度为n的每一个元素去乘 长度为m的每个元素

构造出n*m个数字。

构造方法是:前n-1个(m个)数字为2最后一个是(n-2)(或 (m-2)) 可以证明确实正确。

附别人题解报告一份。

http://codeforces.com/contest/417/submission/6398158

RCC 2014 Warmup (Div. 2) 蛋疼解题总结的更多相关文章

  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. 2) A~C

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

  4. RCC 2014 Warmup (Div. 1)

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

  5. Codeforces Round 319 # div.1 & 2 解题报告

    Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...

  6. Codeforces Round #342 (Div 2) 解题报告

    除夕夜之有生之年CF第一场 下午从奶奶家回到姥姥家,一看还有些时间,先吃点水果陪姥姥姥爷聊了会儿,再一看表,5:20....woc已经开场20分钟了...于是抓紧时间乱搞.. **A. Guest F ...

  7. Codeforces Round #232 (Div. 1) A 解题报告

    A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...

  8. [Codeforces Round #194 (Div. 2)] Secret 解题报告 (数学)

    题目链接:http://codeforces.com/problemset/problem/334/C 题目: 题目大意: 给定数字n,要求构建一个数列使得数列的每一个元素的值都是3的次方,数列之和S ...

  9. CodeForces - 417E(随机数)

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

随机推荐

  1. Django day 36 支付宝支付,微信推送

    一:支付宝支付, 二:微信推送

  2. 转载使用 ContentObsever 拦截短信,获取短信内容

    在一些应用上,比如手机银行,QQ,微信等,很多时候我们都需要通过发送验证码到手机上,然后把验证码填上去,然后才能成功地继续去做下面一步事情. 而如果每次我们都要离开当前界面,然后去查收短信,记住验证码 ...

  3. C. Coin Troubles 有依赖的背包 + 完全背包变形

    http://codeforces.com/problemset/problem/283/C 一开始的时候,看着样例不懂,为什么5 * a1 + a3不行呢?也是17啊 原来是,题目要求硬币数目a3 ...

  4. [转]MySQL存储过程

    转自:http://www.cnblogs.com/exmyth/p/3303470.html 14.1.1 创建存储过程 MySQL中,创建存储过程的基本形式如下: CREATE PROCEDURE ...

  5. 最简单的SPA(单页应用)实现

    $(function(){ var replacePage = function(href, onFinish){ $.get(href,{},function(raw){ var data = ra ...

  6. [转]ASP.NET MVC的帮助类HtmlHelper和UrlHelper

    本文转自:http://www.cnblogs.com/greatandforever/archive/2010/04/20/1715914.html?login=1 在ASP.NET MVC框架中没 ...

  7. SpringBoot 2.x (1):手动创建项目与自动创建项目

    SpringBoot 2.x基于Spring Framework 5.x 环境需求如下: JDK1.8或以上 Maven3.2或以上 这里我使用的是Eclipse,IDEA这个工具很强大,但不习惯它 ...

  8. opencv3.31+vs2015终于配置成功了

    风萧萧兮易水寒, 熬了几个夜晚,终于把opencv配好了, 来图一 唉试了很多方法,终于成功. 教程和资料会发在个人网站里. 测试 代码 #include <iostream> #incl ...

  9. NX自动出图

    小秀一下战果: 1. 自动添加图框2. 自动添加投影视图3. 自动标注外形尺寸4. 根据工艺要求,自动添加公差5. 自动孔表6. 批量打印 欢迎大家积极吐槽哈 [视频演示] http://v.youk ...

  10. github与git常用的一些基本配置与命令

    首次Git设置:ssh-keygen -t ras -C "email@xxx" 生成SSH (共钥)将生成的SSH key复制到文本框中即可(title默认为邮箱名) 你的身份( ...