您的位置:首页 > 其它

cf(413A,B,C)

2015-11-28 16:59 197 查看
A. Data Recovery

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.

The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer
in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.

The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant
wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n,m, min, max and
the list of m temperatures determine whether you can upgrade the set of m temperatures
to the set of n temperatures (that is add n - m temperatures),
so that the minimum temperature was min and the maximum one was max.

Input

The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100).
The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) —
the temperatures reported by the assistant.

Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.

Output

If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect'
(without the quotes).

Sample test(s)

input
2 1 1 2
1


output
Correct


input
3 1 1 3
2


output
Correct


input
2 1 1 3
2


output
Incorrect


Note

In the first test sample one of the possible initial configurations of temperatures is [1, 2].

In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].

In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.

超级水。。

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
int a[105];
int main()
{
int n,m,min,max,flag=0;
cin>>n>>m>>min>>max;
int t=m+2;
for(int i=0;i<m;i++)
{
cin>>a[i];
if(a[i]<min||a[i]>max)
flag=1;
else if(a[i]==min)
t--;
else if(a[i]==max)
t--;
}
if(flag||t>n)
cout<<"Incorrect"<<endl;
else cout<<"Correct"<<endl;
return 0;
}


B. Spyke Chatting

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

The R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming
challenging. For that, R2 uses a famous instant messaging program Spyke.

R2 has m Spyke chats just to discuss all sorts of issues. In each chat, some group of employees exchanges messages daily. An employee
can simultaneously talk in multiple chats. If some employee is in the k-th chat, he can write messages to this chat and receive notifications
about messages from this chat. If an employee writes a message in the chat, all other participants of the chat receive a message notification.

The R2 company is conducting an audit. Now the specialists study effective communication between the employees. For this purpose, they have a chat log and the description of chat structure. You, as one of audit specialists, are commissioned to write a program
that will use this data to determine the total number of message notifications received by each employee.

Input

The first line contains three space-separated integers n, m and k (2 ≤ n ≤ 2·104; 1 ≤ m ≤ 10; 1 ≤ k ≤ 2·105) —
the number of the employees, the number of chats and the number of events in the log, correspondingly.

Next n lines contain matrix a of
size n × m, consisting of numbers zero and one. The element of this matrix, recorded in the j-th
column of the i-th line, (let's denote it as aij)
equals 1, if the i-th
employee is the participant of the j-th chat, otherwise the element equals 0.
Assume that the employees are numbered from 1 to n and
the chats are numbered from 1 to m.

Next k lines contain the description of the log events. The i-th
line contains two space-separated integers xi and yi(1 ≤ xi ≤ n; 1 ≤ yi ≤ m) which
mean that the employee number xi sent
one message to chat number yi.
It is guaranteed that employee number xi is
a participant of chat yi.
It is guaranteed that each chat contains at least two employees.

Output

Print in the single line n space-separated integers, where the i-th
integer shows the number of message notifications the i-th employee receives.

Sample test(s)

input
3 4 5
1 1 1 1
1 0 1 1
1 1 0 0
1 1
3 1
1 3
2 4
3 2


output
3 3 1


input
4 3 4
0 1 1
1 0 1
1 1 1
0 0 0
1 2
2 1
3 1
1 3


output
0 2 3 0


不可以直接暴力模拟。。。。只好想办法dp一下了。。。。

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
int a[20010][15],xx[20010]={0},dp[15]={0};
int vis[20010][15]={{0}};
int main()
{
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf("%d",&a[i][j]);
for(int i=0;i<k;i++)
{
int x,y;
scanf("%d%d",&x,&y);
vis[x][y]++;
dp[y]++;
}

for(int i=1;i<=n;i++)
{
int t=0;
for(int j=1;j<=m;j++)
{
if(a[i][j]&&vis[i][j])
t+=dp[j]-vis[i][j];
else if(a[i][j]&&!vis[i][j])
t+=dp[j];
}
printf("%d ",t);
}

for(int i=1;i<=n;i++)

return 0;
}


C. Jeopardy!

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the finals: company R1 and company R2.

The finals will have n questions, m of
them are auction questions and n - m of them are regular questions. Each question has a price. The price of the i-th
question is ai points.
During the game the players chose the questions. At that, if the question is an auction, then the player who chose it can change the price if the number of his current points is strictly larger than the price of the question. The new price of the question
cannot be less than the original price and cannot be greater than the current number of points of the player who chose the question. The correct answer brings the player the points equal to the price of the question. The wrong answer to the question reduces
the number of the player's points by the value of the question price.

The game will go as follows. First, the R2 company selects a question, then the questions are chosen by the one who answered the previous question correctly. If no one answered the question, then the person who chose last chooses again.

All R2 employees support their team. They want to calculate what maximum possible number of points the R2 team can get if luck is on their side during the whole game (they will always be the first to correctly answer questions). Perhaps you are not going to
be surprised, but this problem was again entrusted for you to solve.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 100; m ≤ min(n, 30)) —
the total number of questions and the number of auction questions, correspondingly. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 107) —
the prices of the questions. The third line contains m distinct integers bi (1 ≤ bi ≤ n) —
the numbers of auction questions. Assume that the questions are numbered from 1 to n.

Output

In the single line, print the answer to the problem — the maximum points the R2 company can get if it plays optimally well. It is guaranteed that the answer fits into the integer 64-bit signed type.

Sample test(s)

input
4 1
1 3 7 5
3


output
18


input
3 2
10 3 8
2 3


output
40


input
2 2
100 200
1 2


output
400


神坑题,数据卡死人。。。。。

给几组数据做参考:

5 3
1819638 2087365 162773 9531053 130978
3 1 4

out 46997584

25 24
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

out 70368752566272


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;

struct data
{
ll w;
bool x;
}a[105];

bool cmp(data a,data b)
{
if(a.x==b.x&&a.x==1)
return a.w<b.w;
return a.x>b.x;
}

int main()
{
ll s=0;
int n,m,bj=-1;
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>a[i].w,a[i].x=0,s+=a[i].w;
for(int i=0;i<m;i++)
{int t;cin>>t;a[t-1].x=1;s-=a[t-1].w;bj++;}
sort(a,a+n,cmp);
//for(int i=0;i<n;i++)
// cout<<a[i].w<<':'<<a[i].x<<' ';cout<<endl;
//cout<<bj<<endl;
int k=bj;
ll ss=s+a[k].w;
for(int i=0;i<=bj;i++)
{
//cout<<i<<' '<<s<<' '<<bj<<endl;
if(s>a[i].w)
s<<=1;
else if(s<=a[i].w)
s+=a[bj--].w,i--;
// cout<<i<<' '<<s<<' '<<bj<<endl<<endl;
}
bj=k-1;
//cout<<bj<<' '<<k<<endl;
for(int i=0;i<k;i++)
{
//cout<<i<<' '<<ss<<' '<<bj<<endl;
if(ss>a[i].w)
ss<<=1;
else if(ss<=a[i].w)
ss+=a[bj--].w,i--;
}
//cout<<ss<<endl;
cout<<max(s,ss)<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: