A. Vladik and Courtesy

time limit per test:2 seconds
memory limit per test:256 megabytes
input:standard input
output:standard output

At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same reason gave 3 candies to Valera in next turn.

More formally, the guys take turns giving each other one candy more than they received in the previous turn.

This continued until the moment when one of them couldn’t give the right amount of candy. Candies, which guys got from each other, they don’t consider as their own. You need to know, who is the first who can’t give the right amount of candy.

Input

Single line of input data contains two space-separated integers a, b (1 ≤ a, b ≤ 109) — number of Vladik and Valera candies respectively.

Output

Pring a single line "Vladik’’ in case, if Vladik first who can’t give right amount of candy, or "Valera’’ otherwise.

Examples
Input
1 1
Output
Valera
Input
7 6
Output
Vladik
Note

Illustration for first test case:

Illustration for second test case:

题目链接:http://codeforces.com/contest/811/problem/A

分析:感觉没什么说的,照着写吧,我也不知道该死的竟然WA了三发,QAQ

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(int i=;;i+=)
{
if(n>=i)
n-=i;
else
{
printf("Vladik\n");
return ;
}
if(m>=i+)
m-=(i+);
else
{
printf("Valera\n");
return ;
}
}
}
return ;
}

B. Vladik and Complicated Book

time limit per test:2 seconds
memory limit per test:256 megabytes
input:standard input
output:standard output

Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p1, p2, ..., pn], where pi denotes the number of page that should be read i-th in turn.

Sometimes Vladik’s mom sorted some subsegment of permutation P from position l to position r inclusive, because she loves the order. For every of such sorting Vladik knows number x — what index of page in permutation he should read. He is wondered if the page, which he will read after sorting, has changed. In other words, has px changed? After every sorting Vladik return permutation to initial state, so you can assume that each sorting is independent from each other.

Input

First line contains two space-separated integers n, m (1 ≤ n, m ≤ 104) — length of permutation and number of times Vladik's mom sorted some subsegment of the book.

Second line contains n space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ n) — permutation P. Note that elements in permutation are distinct.

Each of the next m lines contains three space-separated integers li, ri, xi (1 ≤ li ≤ xi ≤ ri ≤ n) — left and right borders of sorted subsegment in i-th sorting and position that is interesting to Vladik.

Output

For each mom’s sorting on it’s own line print "Yes", if page which is interesting to Vladik hasn't changed, or "No" otherwise.

Examples
Input
5 5
5 4 3 2 1
1 5 3
1 3 1
2 4 3
4 4 4
2 5 3
Output
Yes
No
Yes
Yes
No
Input
6 5
1 4 3 2 5 6
2 4 3
1 6 2
4 5 4
1 3 3
2 6 3
Output
Yes
No
Yes
No
Yes
Note

Explanation of first test case:

  1. [1, 2, 3, 4, 5] — permutation after sorting, 3-rd element hasn’t changed, so answer is "Yes".
  2. [3, 4, 5, 2, 1] — permutation after sorting, 1-st element has changed, so answer is "No".
  3. [5, 2, 3, 4, 1] — permutation after sorting, 3-rd element hasn’t changed, so answer is "Yes".
  4. [5, 4, 3, 2, 1] — permutation after sorting, 4-th element hasn’t changed, so answer is "Yes".
  5. [5, 1, 2, 3, 4] — permutation after sorting, 3-rd element has changed, so answer is "No".

题目链接:http://codeforces.com/contest/811/problem/B

分析:给出一个1~n的排列 m次询问一个区间[l,r]排序后原来x位置的数是否改变

可以直接找[l,r]中x的值的前面的数字个数,然后判断b==x-l+1是否成立,成立为Yes!

下面给出AC代码:

 #include<bits/stdc++.h>
using namespace std;
int n,m,a[],b;
int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
scanf("%d",a+i);
for(int i=;i<=m;i++)
{
int l,r,x;
scanf("%d%d%d",&l,&r,&x);
b=;
for(int i=l;i<=r;i++)
if(a[i]<=a[x])
b++;
puts(b==x-l+?"Yes":"No");
}
return ;
}

Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)的更多相关文章

  1. Codeforces Round #416 (Div. 2) A. Vladik and Courtesy【思维/模拟】

    A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  2. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  3. Codeforces Round #556 (Div. 2) - C. Prefix Sum Primes(思维)

    Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Descripti ...

  4. Codeforces Round #523 (Div. 2) F. Katya and Segments Sets (交互题+思维)

    https://codeforces.com/contest/1061/problem/F 题意 假设存在一颗完全k叉树(n<=1e5),允许你进行最多(n*60)次询问,然后输出这棵树的根,每 ...

  5. Codeforces Round #426 (Div. 2)【A.枚举,B.思维,C,二分+数学】

    A. The Useless Toy time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  6. Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 水题

    C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just re ...

  7. Codeforces Round #706 (Div. 2)B. Max and Mex __ 思维, 模拟

    传送门 https://codeforces.com/contest/1496/problem/B 题目 Example input 5 4 1 0 1 3 4 3 1 0 1 4 3 0 0 1 4 ...

  8. Codeforces Round #272 (Div. 2) C. Dreamoon and Sums (数学 思维)

    题目链接 这个题取模的时候挺坑的!!! 题意:div(x , b) / mod(x , b) = k( 1 <= k <= a).求x的和 分析: 我们知道mod(x % b)的取值范围为 ...

  9. Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题

    A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

随机推荐

  1. windos10安装mongodb并配置

    想了想还是把这个写上吧,毕竟网上的教程有不少坑的. 首先下载mongodb,如果你嫌官网慢,那么你可以去我的百度云下载 链接:http://pan.baidu.com/s/1pKEWTBX 密码:v3 ...

  2. 常规流(Normal flow)

    连我自己把float和绝对定位,都称为脱离文档流,想想概念又不那么清晰,于是寻找了W3C资料来理解,才发觉不应该叫文档流. 资料 英文:https://www.w3.org/TR/CSS22/visu ...

  3. 【WebGL】《WebGL编程指南》读书笔记——第3章

    一.前言 根据前面一章的内容,继续第三章的学习. 二.正文       一起绘制三个点,这里要使用到缓存了 var n = initVertexBuffers(gl); //返回绘制点的个数 n ) ...

  4. 限制ssh远程登陆

    超过十次,就添加到hosts.deny里面去 #!/bin/bash date=`date +%Y%m%d` file="/var/log/secure" max=10 if [[ ...

  5. Java基础之引用(String,char[],Integer)总结

    1.String的引用: 下列代码执行后的结果为: public class Test { public static void main(String[] args) { StringBuffer  ...

  6. JAVA模板方法

    package project01; abstract class MyRuntime{ public final void runtime(){ long starttime =System.cur ...

  7. Material Theme 文件名的标签(tab)被大写了

    我们平时使用的都是小写的,今天第一次使用Material Theme 这个发现标签被大写了,百度后没找到然后自己找了找设置,解决了 原来是这样的, 设置如下 设置后: 希望能帮到有同样问题的同学

  8. SQL基础学习_02_查询

    SELECT语句 1. SELECT语句查询列(字段):     SELECT <列名>    FROM <表名>;     该语句使用了两个SQL子句,SELECT子句列举了 ...

  9. Java Web高级编程(四)

    WebSocket 一.WebSocket的产生 用户希望Web页面可以进行交互,用于解决这个问题的技术是JavaScript,现在Web上有许多的可用的JavaScript框架,在使用极少的Java ...

  10. MSSQLSERVER并行度

    Microsoft SQL Server最大并行度(MAXDOP) 配置选项控制并行计划用于执行查询的处理器的数目.此选项确定用于执行工作并行查询计划运算符的计算和线程资源.根据是否 SQL Serv ...