Codeforces Round #450 (Div. 2)ABC

A. Find Extra One

You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.

Input

The first line contains a single positive integer n (2 ≤ n ≤ 105).

The following n lines contain coordinates of the points. The i-th of these lines contains two single integers xi and yi (|xi|, |yi| ≤ 109, xi ≠ 0). No two points coincide.

Output

Print "Yes" if there is such a point, "No" — otherwise.

You can print every letter in any case (upper or lower).

Examples

Input

31 1-1 -12 -1

Output

Yes

Input

41 12 2-1 1-2 2

Output

No

Input

31 22 14 60

Output

Yes

Note

In the first example the second point can be removed.

In the second example there is no suitable for the condition point.

In the third example any point can be removed.

是否存在删除一个点后所以的点都在x=0的一侧,只要判断在两侧是否有小于2个的点就行。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3
 4 int main() {
 5     int n;
 6     int ans = 0, ans1 = 0;
 7     cin >> n;
 8     for(int i = 0; i < n; i ++) {
 9         int x, y;
10         cin >> x >> y;
11         if(x < 0) ans++;
12         else ans1++;
13     }
14     if(ans <= 1 || ans1 <= 1) printf("Yes\n");
15     else printf("No\n");
16     return 0;
17 }

B. Position in Fraction

You have a fraction . You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.

Input

The first contains three single positive integers a, b, c (1 ≤ a < b ≤ 105, 0 ≤ c ≤ 9).

Output

Print position of the first occurrence of digit c into the fraction. Positions are numbered from 1 after decimal point. It there is no such position, print -1.

Examples

Input

1 2 0

Output

2

Input

2 3 7

Output

-1

Note

The fraction in the first example has the following decimal notation: . The first zero stands on second position.

The fraction in the second example has the following decimal notation: . There is no digit 7 in decimal notation of the fraction.

判断c是在a/b的十进制中的小数第几位,没有就输出-1. 主要是模拟除法。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main() {
 4     int a, b, c, cnt = 0;
 5     cin >> a >> b >> c;
 6     a %= b;
 7     for(int i = 0; i < 1000; i ++) {
 8         if(a*10 < b && c == 0) return 0*printf("%d\n",cnt+1);
 9         while(a < b) {
10             a*= 10,cnt++;
11         }
12
13         int tmp = a/b;
14         if(tmp == c) return 0*printf("%d\n",cnt);
15         a -= tmp*b;
16         if(a == 0) {
17             if(c == 0) return 0*printf("%d\n",cnt+1);
18             break;
19         }
20     }
21     printf("-1\n");
22     return 0;
23 }

C. Remove Extra One

You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.

We remind that in a sequence of numbers a1, a2, ..., ak the element ai is a record if for every integer j (1 ≤ j < i) the following holds: aj < ai.

Input

The first line contains the only integer n (1 ≤ n ≤ 105) — the length of the permutation.

The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the permutation. All the integers are distinct.

Output

Print the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.

Examples

Input

11

Output

1

Input

55 1 2 3 4

Output

5

Note

In the first example the only element can be removed.

求删掉哪个数可以使的record数量最大,换句话来说就是删除哪个数可以增加的record最多。

在当前元素a[i]时有三种情况。max1为a[i]前面的最大值,max2为a[i]前面的次大值。

一、max2 < max1 < a[i] 删除a[i]的话会使得record减一

二、max2 < a[i] < max1 输出a[i]既不会增加也不会减少,但删除max1会使得a[i]变成record。

三、a[i] < max1 < max2 删除哪一个都不会有影响。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int N = 1e5+10;
 4 int a[N], cnt[N];
 5 vector<int> vs;
 6 int main() {
 7     int n;
 8     int max1 = 0, max2 = 0;
 9     cin >> n;
10     for(int i = 1; i <= n; i++) {
11         cin >> a[i];
12         if(max1 < a[i]) {
13             max2 = max1;
14             max1 = a[i];
15             cnt[a[i]]--;
16         } else if(max2 < a[i]) {
17             cnt[max1]++;
18             max2 = a[i];
19         }
20     }
21     int MAX = -1000000, ans = 0;
22     for(int i = 1; i <= n; i ++) {
23         if(cnt[i] > MAX) {
24             ans = i;
25             MAX = cnt[i];
26         }
27     }
28     printf("%d\n",ans);
29     return 0;
30 }
时间: 2024-08-30 13:24:31

Codeforces Round #450 (Div. 2)ABC的相关文章

Codeforces Round #247 (Div. 2) ABC

Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431 代码均已投放:https://github.com/illuz/WayToACM/tree/master/CodeForces/431 A - Black Square 题目地址 题意: Jury玩别踩白块,游戏中有四个区域,Jury点每个区域要消耗ai的卡路里,给出踩白块的序列,问要消耗多少卡路里. 分析: 模拟水题.. 代码: /* * Author: illuz

Codeforces Round #450 (Div. 2)

Codeforces Round #450 (Div. 2) http://codeforces.com/contest/900 A 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define eb

Codeforces Round #366 (Div. 2) ABC

Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 1 #I hate that I love that I hate it 2 n = int(raw_input()) 3 s = "" 4 a = ["I hate that ","I love that ", "I hate it","I love it"] 5 fo

Codeforces Round #451 (Div. 2) ABC

A. Rounding Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded. For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 

Codeforces Round #312 (Div. 2) ABC题解

[比赛链接]click here~~ A. Lala Land and Apple Trees: [题意]: AMR住在拉拉土地.拉拉土地是一个非常美丽的国家,位于坐标线.拉拉土地是与著名的苹果树越来越随处可见. 拉拉土地恰好n苹果树.树数i位于位置xi和具有人工智能的苹果就可以了增长.阿姆鲁希望从苹果树收集苹果. AMR目前维持在X =0的位置.在开始的时候,他可以选择是否去左边或右边.他会在他的方向继续下去,直到他遇见一棵苹果树,他之前没有参观.他会采取所有的苹果,然后扭转他的方向,继续走这

Codeforces Round #429 (Div. 2)ABC

A: 题意:n个东西,k个朋友,全部给朋友,每个朋友不可以拿同样的,问是否可行 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 map<char ,int >ma; 5 int main(){ 6 int n,k; 7 cin>>n>>k; 8 string s; 9 cin>>s; 10 for(int i=0;i<n;i++){ 11 ma[s[i]]++; 12 if(ma[s

Codeforces Round #443 (Div. 2)ABC

A. Borya's Diagnosis It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Bor

Codeforces Round #450 (Div. 2) ABCD

这次还是能看的0 0,没出现一题掉分情况. QAQ前两次掉分还被hack了0 0,两行清泪. A. Find Extra One You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis. Input

Codeforces Round #500 (Div. 2) ABC

A. Piles With Stones 水题略 B. And 题意:让输入一个n,一个下,之后输入一个长为n的数组a,可以在a中使a变为a&x,问经过几次变化数组中有相同的数 思路:当数组中有两个相同的数时直接输出0,注意a&x后的数无论在与x经过几次按位与运算都不会发生变化, 该题有特殊情况,在数据相当大时可能出现错误,因此要ans=min(ans,1或2),在这最后系统wa了,难受emmmmm 知识点补充:只有1&1=1 代码: #include <bits/stdc+