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. linux学习之路6 Vi文本编辑器

    vim是vi的增强版本 vim拥有三种模式: 命令模式(常规模式) vim启动后,默认进入命令模式.任何模式都可以通过按esc键回到命令模式(可以多按几次.命令模式可以通过键入不同的命令完成选择.复制 ...

  2. 用SpringMVC实现的上传下载方式二(多文件上传)

    参考来源:      http://blog.csdn.net/qq_32953079/article/details/52290208 1.导入相关jar包 commons-fileupload.j ...

  3. 视图解析器InternalResourceViewResolver在什么情况下需要配置?在什么情况下不需要配置?

    如果路径名是逻辑名的话,必须配置 -------------- 相对路径,即逻辑名称如果路径名是真实名的话,可选配置 若是绝对路径,则不用配置,即真实名称 注:试一下逻辑名和真实名的例子*****有用 ...

  4. 专题六:UDP编程

    引用: 前一个专题简单介绍了TCP编程的一些知识,UDP与TCP地位相当的另一个传输层协议,它也是当下流行的很多主流网络应用(例如QQ.MSN和Skype等一些即时通信软件传输层都是应用UDP协议的) ...

  5. STL容器迭代过程中删除元素技巧(转)

    1.连续内存序列容器(vector,string,deque) 序列容器的erase方法返回值是指向紧接在被删除元素之后的元素的有效迭代器,可以根据这个返回值来安全删除元素. vector<in ...

  6. document.write清除原有内容情况

    原博客: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta ...

  7. Fiddler——抓包工具的使用

    fiddler安装 pc端安装fiddler,自行从百度下载即可 Fiddler是强大且好用的Web调试工具之一,它能记录客户端和服务器的http和https请求,允许你监视,设置断点,甚至修改输入输 ...

  8. SpringBoot项目编译后没有xxxmapper.xml文件解决方法

    在pom.xml文件中添加如下代码 <build> <plugins> <plugin> <groupId>org.springframework.bo ...

  9. Introduction of Version Control/Git, SVN

    什么是版本控制? 你可以把一个版本控制系统(缩写VCS)理解为一个“数据库”,在需要的时候,它可以帮你完整地保存一个项目的快照.当你需要查看一个之前的快照(称之为“版本”)时,版本控制系统可以显示出当 ...

  10. 04Microsoft SQL Server 数据库创建,查看,使用,修改及删除

    Microsoft SQL Server 数据库创建,查看,使用,修改及删除 创建数据库 创建普通数据库 USE [master] GO CREATE DATABASE [MyDataBase] -- ...