Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)

时间:2023-01-13 14:09:10

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:

Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)

Illustration for second test case:

Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)

题目链接: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 &num;416 &lpar;Div&period; 2&rpar; A&period; Vladik and Courtesy【思维&sol;模拟】

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

  2. Codeforces Round &num;368 &lpar;Div&period; 2&rpar; A&period; Brain&&num;39&semi;s Photos (水题)

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

  3. Codeforces Round &num;556 &lpar;Div&period; 2&rpar; - C&period; Prefix Sum Primes(思维)

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

  4. Codeforces Round &num;523 &lpar;Div&period; 2&rpar; F&period; Katya and Segments Sets &lpar;交互题&plus;思维&rpar;

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

  5. Codeforces Round &num;426 &lpar;Div&period; 2&rpar;【A&period;枚举,B&period;思维,C&comma;二分+数学】

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

  6. Codeforces Round &num;373 &lpar;Div&period; 2&rpar; C&period; Efim and Strange Grade 水题

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

  7. Codeforces Round &num;272 &lpar;Div&period; 2&rpar; C&period; Dreamoon and Sums &lpar;数学 思维&rpar;

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

  8. Codeforces Round &num;185 &lpar;Div&period; 2&rpar; A&period; Whose sentence is it&quest; 水题

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

  9. Codeforces Round&num;416 Div&period;2

    A. Vladik and Courtesy 题面 At regular competition Vladik and Valera won a and b candies respectively. ...

随机推荐

  1. 第十九篇:提高SOUI应用程序渲染性能的三种武器

    SOUI是一套100%开源的基于DirectUI的客户端开发框架. 基于DirectUI设计的UI虽然UI呈现的效果可以很炫,但是相对于传统的win32应用程序中每个控件一个窗口句柄的形式,渲染效率是 ...

  2. org&period;apache&period;catalina&period;LifecycleException

    web.xml中<url-pattern>.do</url-pattern>改为<url-pattern>*.do</url-pattern> 1 严重 ...

  3. 返回绝对值--Math&period;Abs 方法

    Math.abs()  返回指定数字的绝对值.

  4. 9、网页制作Dreamweaver(jQuery基础&colon;事件)

    事件 定义 即当HTML中发生某些事(点击.鼠标移过等)的时候调用的方法 $(selector).action() 触发 事件的触发有两种方法: 1.直接将事件click写在<javascrip ...

  5. SharedPreferencesUtil

    用于缓存一个临时的变量 比如 SharedPreferencesUtil.put(getApplicationContext(), "userImage", user.conten ...

  6. Windows下用Git下载android源码 转载

    http://my.oschina.net/jiadebin/blog/52631 1.首先你的电脑要安装好git,这个请参考git官网. 2.打开git命令窗口输入git clone http:// ...

  7. delphi datasnap 心跳包

    为了能让我们的服务程序更加稳定,有些细节问题必须解决.就如上一讲中提到的客户端拔掉网线,造成服务器上TCP变成死连接,如果死连接数量过多,对服务器能长期稳定运行是一个巨大的威胁.另外,经过测试,如果服 ...

  8. 使用nodejs的http模块创建web服务器

    使用nodejs的http模块创建web服务器 laiqun@msn.cn Contents 1. web服务器基础知识 2. Node.js的Web 服务器 3. 代码实现 1. web服务器基础知 ...

  9. 随心测试&lowbar;软测基础&lowbar;007&lt&semi;软测学习路线建议&gt&semi;

    如果你对软测感兴趣,那么如何学习软件测试呢? 贴心小提示:以下内容,仅供参考,不挖坑 1:学习方式_职业教育选择观 ————SX的观点:成本 | 收益说,理性接受 软测产业服务链中,测试工程师重在于& ...

  10. find mtime参数&plus;号,-号,不带符号的用法

     find . -mtime +0 -type f -name "oms*" | xargs rm -f 删除24小时以前 oms格式的文件     #按文件更改时间来查找文件,- ...