Gym 100703L Many questions 水题
2015-07-27 20:03
435 查看
L. Many questionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard 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.
InputThe 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.
OutputIn 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
题目链接: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);
for(int i = 1; i <= n; i++) {
scanf("%d", &q[i]);
}
for(int i = 1; i <= n; i++) {
scanf("%d", &c[i]);
}
for(int i = 1; i <= n; i++) {
scanf("%d", &p[i]);
}
int ans1 = 0, ans2 = 0;
for(int i = 1; i <= n; i++) {
int x = abs(q[i] - p[i]);
int y = abs(c[i] - p[i]);
if(x < y) ans1++;
else if(x > y) ans2++;
}
printf("%d %d\n", ans1, ans2);
return 0;
}
— 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.
InputThe 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.
OutputIn 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 5output
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);
for(int i = 1; i <= n; i++) {
scanf("%d", &q[i]);
}
for(int i = 1; i <= n; i++) {
scanf("%d", &c[i]);
}
for(int i = 1; i <= n; i++) {
scanf("%d", &p[i]);
}
int ans1 = 0, ans2 = 0;
for(int i = 1; i <= n; i++) {
int x = abs(q[i] - p[i]);
int y = abs(c[i] - p[i]);
if(x < y) ans1++;
else if(x > y) ans2++;
}
printf("%d %d\n", ans1, ans2);
return 0;
}
相关文章推荐
- Gym 100703L Many questions 水题
- IOS--UI--LessonXib 可视化编程
- legacy boot与uefi boot
- hdu 2506 Buildings
- USACO——Sorting a Three-Valued Sequence
- [LeetCode] Unique Paths
- UI第一课,view视图,label 和一些常用方法
- UIResponder
- PHP中include和require的区别详解
- codeforces Gym 100500H H. ICPC Quest 水题
- IOS--UI 电影列表纯代码
- EasyUI TextBox的keypress
- iOS UI篇 学习笔记 UILabel
- PAT (Advanced Level) 1056. Mice and Rice (25) 模拟比赛,用queue辅助
- 初学iOS UI 用于交流与学习
- UESTC 94 Bracket Sequence(线段树的区间更新)
- PAT 1099. Build A Binary Search Tree (30)
- flash builder 配置中如果有中文会报错
- iOS - UI-归档解归档
- POJ 2785 4 Values whose Sum is 0 (对半分解 二分搜索)