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.




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值