Gym 100703L Many questions 水题

L. Many questions
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

— How could I have forgotten? Knight is going to visit me today, — no matter how Dragon tried to be cunning, he was not very good at it, — I think, it will be interesting for you to make the acquaintance with him.

— Perhaps, we are somewhat acquainted already, — Princess smiled, — But it rarely happens to see each other: different people, different interests...

Dragon believed that common interests are not the most important things. The most important is to have the similar similar opinions on matters of principle. Dragon had a list of questions he had asked Knight and Prince already. He was going to ask Princess these questions.

Let's consider that an answer to a question is a positive integer. If the absolute value of difference between Knight's and Princess' answers is less than one of Prince's and Princess', Dragon believes that Knight's and Princess' opinions are more similar. And vice versa, if the absolute value of difference between Prince's and Princess' answers is less than one of Knight's and Princess', Dragon believes that Knight's and Princess' opinions are more similar. Dragon ignores the questions the values of which are equal.

Your task is figure out how many questions, in which Princess' and Prince's opinions are more similar, exist and how many questions, in which Princess' and Knight's opinions are more similar, exist.

Input

The first line contains integer n (1 ≤ n ≤ 1000) — the number of Dragon's questions.

The second line contains n integers p1, p2, ..., pn — Prince's answers on Dragon questions.

The third line contains n integers k1, k2, ..., kn — Knight's answers on Dragon's questions.

The fourth line contains n integers r1, r2, ..., rn — Princess' answers on Dragon questions.

All answers are positive integer not greater than 100.

Output

In the first line print two space-separated integers — the number of questions in which Princess' and Prince's opinions are more similar and the number of questions in which Princess' and Knight's opinions are more similar.

Sample test(s)
input
7 1 5 24 11 82 100 7 6 3 85 78 14 32 33 2 4 64 35 55 61 5 
output
4 2

 

题目链接:http://codeforces.com/gym/100703/problem/L

AC代码:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 #define MAXN 1100 //1e6
 5 #define y1 y234
 6 int n;
 7 int q[MAXN], c[MAXN], p[MAXN];
 8 int main() {
 9     scanf("%d", &n);
10     for(int i = 1; i <= n; i++) {
11         scanf("%d", &q[i]);
12     }
13     for(int i = 1; i <= n; i++) {
14         scanf("%d", &c[i]);
15     }
16     for(int i = 1; i <= n; i++) {
17         scanf("%d", &p[i]);
18     }
19     int ans1 = 0, ans2 = 0;
20     for(int i = 1; i <= n; i++) {
21         int x = abs(q[i] - p[i]);
22         int y = abs(c[i] - p[i]);
23         if(x < y) ans1++;
24         else if(x > y) ans2++;
25     }
26     printf("%d %d\n", ans1, ans2);
27     return 0;
28 }

 


posted @ 2015-07-27 20:03  gaoxiang36999  阅读(181)  评论(0编辑  收藏  举报