您的位置:首页 > 产品设计 > UI/UE

URAL 1880 Psych Up's Eigenvalues

2014-07-18 19:36 417 查看

1880. Psych Up's Eigenvalues

Time limit: 0.5 second
Memory limit: 64 MB

At one of the contests at the Petrozavodsk Training Camp, players of
the Psych Up team quickly found the simple problem and Fedya sat at the
computer. The solution was ready in five minutes. Without spending time
for testing, Fedya submitted it and in a few seconds got Time Limit
Exceeded.

Fedya crumpled the problem statement and left the room slamming the
door behind him. Things were going the wrong way and he needed to wind
down. On his way to the restroom Fedya heard a conversation of the contest
authors. Pasha was discussing with his friend the solution of the problem
for which Fedya had got TLE. Fedya could only discern the word
“eigenvalues.”

Fedya thought about it and decided that he, for sure, had his eigenvalues.
For example, the date of birth, the number of his apartment, the mark he
had got at the latest exam, or the number of travels to contests. But they
had a team contest, so what was their team's eigenvalue? Of course, a
number was a team's eigenvalue if it was an eigenvalue for each of its
players. With these joyful thoughts Fedya returned to the contest room.

Input

The input data consist of three blocks two lines each. The first line of
each block contains the number n of a player's eigenvalues (1 ≤ n ≤ 4 000). In the second line you are given n distinct integers in ascending order, which are the eigenvalues. All the eigenvalues are
positive integers not exceeding 109.

Output

Output the number of eigenvalues of the Psych Up team.

Sample

inputoutput
5
13 20 22 43 146
4
13 22 43 146
5
13 43 67 89 146

3


#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int a[4010],b[4010],c[4010];
int main()
{
int t1 = 0, t2 = 0, t3 = 0;
cin>>t1;
for(int i= 0; i < t1; i++)
cin>>a[i];
cin>>t2;
for(int i = 0; i < t2; i++)
cin>>b[i];
cin>>t3;
for(int i=0;i<t3;i++)
cin>>c[i];
int m=0;
int i=0,j=0,k=0;
while(i<t1&&j<t2&&k<t3)
{
int t = min(a[i], min(b[j], c[k]));
if (t == a[i] && t == b[j] && t == c[k])
m++, i++, j++, k++;
else if (t == a[i])
i++;
else if (t == b[j])
j++;
else
k++;
}
printf("%d\n",m);
return 0;
}


View Code

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: