A. Vladik and Courtesy
2 seconds
256 megabytes
 

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, theydon’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 ab (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.

 
input
1 1
output
Valera
input
7 6
output
Vladik
Note:

Illustration for first test case:

Illustration for second test case:

题目大意:

     Vladik and Valera 各有a块和b块糖,他两个轮流送给对方糖果,Vladik and Valera 1块、

     Valera送给Vladik 2块、Vladik and Valera 3块....直到有一方无法送出相应的糖果时结束。

     输出对应的人名。

解题思路:暴力模拟即可。

 #include <stdio.h>
int main ()
{
int a,b;
while (~scanf("%d%d",&a,&b))
{
for (int i = ;a>=&&b>=; i ++)
{
if (i%) a-= i;
else b -= i;
}
if (a < )
printf("Vladik\n");
else
printf("Valera\n");
}
return ;
}
B. Vladik and Complicated Book
 

2 seconds

256 megabytes
 

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 nm (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 lirixi (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.

 
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".

题目大意:

     输入n个整数,然后有m次询问。每次询问输入三个整数L,R,X,将[L,R]范围内的整数从小到大排序,

     判断第X个整数的位置是否发生变化。

解题思路:

     下午写的时候,特意看了下数据范围,发现不是太大就直接sort了。不过最后被无情的hack了。。。。

     后来在codeforces群里看大佬们讨论时提到一种思路,对于每一个询问只用判断[L,R]中小于第X个整数的个数

     是否等于X-L(因为 (1 ≤ li ≤ xi ≤ ri ≤ n) 所以只要在[L,R]中有X-L个整数小于Xi排序之后就不会影响Xi的位置)

 #include <stdio.h>
int main ()
{
int n,m,i,l,r,x;
int p[];
while (~scanf("%d%d",&n,&m))
{
for (i = ; i <= n; i ++)
scanf("%d",&p[i]);
while (m --)
{
int sum = ;
scanf("%d%d%d",&l,&r,&x);
for(i = l; i <= r; i ++)
if (p[i] < p[x])
sum ++;
if (x-l == sum)
printf("Yes\n");
else
printf("No\n");
}
}
return ;
}

最新文章

  1. python之路十三
  2. 学习笔记:HTML5 Canvas绘制简单图形
  3. MySQL 调优/优化的 100 个建议
  4. [译]Node.js Best Practices - Part 2
  5. (原创)鸟哥linux学习script shell相关笔记
  6. MYSQL主从同步测试
  7. 手绘经典QQ头像 请让我一个人呆一会
  8. C++中new和delete的背后( call edx 调用虚表内的第二个函数(析构函数))
  9. jquery-validate的用法
  10. django(注册→登录→主页)增强版
  11. 用bootstrap 分页插件问题
  12. mongodb的设计特征
  13. &#127827; 移动端调试工具之vconsole的使用~ &#127827;
  14. 10树莓派Samba的安装与配置
  15. App拉起小程序提示跳转失败
  16. Java 发送http post 请求
  17. iOS UI-应用管理(使用Cell模板)
  18. TColor转化为字符串
  19. Java并发(八):AbstractQueuedSynchronizer
  20. 从徐飞的文章《Web应用的组件化开发(一)中窥视web应用开发的历史

热门文章

  1. JVM理解
  2. 常见浏览器hack汇总
  3. 获取LAMP与LNMP的编译参数
  4. 牛客练习赛28-B(线段树,区间更新)
  5. java中如何把图片转换成二进制流的代码
  6. UML-6.2-用例-用例模型/用例/场景关系
  7. python入门练习之如何连接数据库
  8. 设置MySQL字符集utf8
  9. sql根据表中数量字段自动复制记录行
  10. jqueyr validtion的使用