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. vux修改css样式的2种办法

      最近手上有个移动端的项目.前端UI框架是选择的VUX.但是在使用的时候经常会发现框架自带的组件样式和我们要求的不一致.经常需要手动覆盖样式.这里记录下我们使用的2种方法. 我们以XHeader组件 ...

  2. Codeforces 1131 (div 2)

    链接:http://codeforces.com/contest/1131 A Sea Battle 利用良心出题人给出的图,不难看出答案为\(2*(h1+h2)+2*max(w1,w2)+4\)由于 ...

  3. 贪心 Codeforces Round #263 (Div. 2) C. Appleman and Toastman

    题目传送门 /* 贪心:每次把一个丢掉,选择最小的.累加求和,重复n-1次 */ /************************************************ Author :R ...

  4. 转 linux shell自定义函数(定义、返回值、变量作用域)介绍

    linux shell 可以用户定义函数,然后在shell脚本中可以随便调用.下面说说它的定义方法,以及调用需要注意那些事项. 一.定义shell函数(define function) 语法: [ f ...

  5. 全面学习ORACLE Scheduler特性(2)管理jobs

    1.2  管理Jobs 1.2.1  启用Jobs 前面创建JOB时,由于未显式的指定ENABLED参数,因此即使指定了START_DATE,不过默认情况下JOB不会自动执行.对于这种情况,DBMS_ ...

  6. java 对readLine扩展添加行号样式

    java 的流的使用中,在字符缓冲输入流中,有一个每次读取一行数据的方法:readLine(): 在这里使用简单的继承方法对其继续扩展,使得返回每行前面添加序号 //需要导入的一些包 import j ...

  7. datagrid 选中某行,翻页再翻回来,发现选中的行没有选中

    不管有没有设置复选框,其实都是一样的,都是idField属性没有设置,加上去即可. $(function(){ $('#dg').datagrid({ url:'ContactServlet', to ...

  8. Scala-基础-运算符

    import junit.framework.TestCase /** * 运算符 */ class Demo3 extends TestCase { def test_+ { var x = 10; ...

  9. poj2240 Arbitrage

    思路: 有向图判负环. 实现: (1)spfa #include <iostream> #include <map> #include <string> #incl ...

  10. 微信小程序打卡第五天

    2018-02-1823:55:53大年初三 微信小程序已经学了5个夜晚了,没有很努力,只是简单地接触,感觉从今天开始有了突破的进展,很爽! 无意间发现一个很好的教程,也是一个老哥分享的,很给力 ht ...