Codeforces Round #450 (Div. 2)

A題水的一批,問你去掉一個點,剩下的點能不能滿足都在y軸一側

B題測試數據超級水,用java隨便加了個長度的限制,就蒙過了。給你三個數a,b,c,問你a/b的小數點後第幾位是c

C題,大部分時間都用來調這個題了,如果我沒理解錯的話,意思就是給你n個數,問你去掉那個數之後,是的剩下的數列中最長上升子序列最大,我用O(nlogn)的一直wa在中間一組測試數據,調通後補發

A. Find Extra One
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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| ≤ 109xi ≠ 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
3
1 1
-1 -1
2 -1
output
Yes
input
4
1 1
2 2
-1 1
-2 2
output
No
input
3
1 2
2 1
4 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.

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define MOD 1000000007
#define N 100005
//ll map[N][2];
int n;
int x=0,y=0;
int main()
{
    ll a,b;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&a,&b);
        if(a>0)
        {
            x++;
        }
    }
    if(x==n||x==n-1||x==0||x==1)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


B. Position in Fraction
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 abc (1 ≤ a < b ≤ 1050 ≤ 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.

import java.math.BigDecimal;
import java.util.Scanner;


public class Main {
   
	 public static BigDecimal bigDiv(String v1, String v2, int scale) {   
	        BigDecimal b1 = new BigDecimal(v1);   
	        BigDecimal b2 = new BigDecimal(v2);   
	        return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP);   
	    }   
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner cin=new Scanner(System.in);
		while(cin.hasNext())
		{	
			double a=cin.nextDouble();
			double b=cin.nextDouble();
			int c=cin.nextInt();
			String temp1=Double.toString(a);
			String temp2=Double.toString(b);
			BigDecimal ans=bigDiv(temp1,temp2,10000);
			//System.out.println(ans);
			int flag=0;
			String s=ans.toString();
			int i;
			for(i=2;i<10000;i++)
			{
				if(s.charAt(i)-'0'==c)
				{
					flag=1;
					break;
				}
			}
			if(flag==1)
				System.out.println(i-1);
			else 
				System.out.println("-1");
		}
	}

}

C. Remove Extra One
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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
1
1
output
1
input
5
5 1 2 3 4
output
5
Note

In the first example the only element can be removed.




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章