A. A Good Contest
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is changed depending on his performance.
Anton wants the color of his handle to become red. He considers his performance in the rated contest to be good if he outscored some participant, whose handle was colored red before the contest and his rating has increased after it.
Anton has written a program that analyses contest results and determines whether he performed good or not. Are you able to do the same?
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of participants Anton has outscored in this contest .
The next n lines describe participants results: i-th} of them consists of a participant handle namei and two integers beforei and afteri ( - 4000 ≤ beforei, afteri ≤ 4000) — participant's rating before and after the contest, respectively. Each handle is a non-empty string, consisting of no more than 10 characters, which might be lowercase and uppercase English letters, digits, characters «_» and «-» characters.
It is guaranteed that all handles are distinct.
Output
Print «YES» (quotes for clarity), if Anton has performed good in the contest and «NO» (quotes for clarity) otherwise.
Examples
Input
3
Burunduk1 2526 2537
BudAlNik 2084 2214
subscriber 2833 2749
Output
YES
Input
3
Applejack 2400 2400
Fluttershy 2390 2431
Pinkie_Pie -2500 -2450
Output
NO
Note
In the first sample, Anton has outscored user with handle Burunduk1, whose handle was colored red before the contest and his rating has increased after the contest.
In the second sample, Applejack's rating has not increased after the contest, while both Fluttershy's and Pinkie_Pie's handles were not colored red before the contest.
#include
#include
using namespace std;
int main()
{
int n;
while(~scanf("%d",&n))
{
int fla=0;
for(int i=0;i=2400&&c>=2400&&c>b)fla=1;
}
if(fla==1)
{
printf("YES\n");
}
else printf("NO\n");
}
}
B. Economy Game
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).
Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?
Please help Kolya answer this question.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.
Output
Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).
Examples
Input
1359257
Output
YES
Input
17851817
Output
NO
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.
#include
#include
using namespace std;
int main()
{
int n;
while(~scanf("%d",&n))
{
int flag=0;
for(int i=0;i<100;i++)
{
for(int j=0;j<1000;j++)
{
if(n-(i*1234567+j*123456)<0)break;
if((n-(i*1234567+j*123456))%1234==0)
{
flag=1;
break;
}
}
if(flag==1)break;
}
if(flag==1)printf("YES\n");
else printf("NO\n");
}
}
C. Heap Operations
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
· put the given number into the heap;
· get the value of the minimum element in the heap;
· extract the minimum element from the heap;
Thus, at any moment of time the heap contains several integers (possibly none), some of them might be equal.
In order to better learn this data structure Petya took an empty heap and applied some operations above to it. Also, he carefully wrote down all the operations and their results to his event log, following the format:
· insert x — put the element with value x in the heap;
· getMin x — the value of the minimum element contained in the heap was equal to x;
· removeMin — the minimum element was extracted from the heap (only one instance, if there were many).
All the operations were correct, i.e. there was at least one element in the heap each time getMin or removeMin operations were applied.
While Petya was away for a lunch, his little brother Vova came to the room, took away some of the pages from Petya's log and used them to make paper boats.
Now Vova is worried, if he made Petya's sequence of operations inconsistent. For example, if one apply operations one-by-one in the order they are written in the event log, results of getMin operations might differ from the results recorded by Petya, and some of getMin or removeMin operations may be incorrect, as the heap is empty at the moment they are applied.
Now Vova wants to add some new operation records to the event log in order to make the resulting sequence of operations correct. That is, the result of each getMin operation is equal to the result in the record, and the heap is non-empty when getMin ad removeMin are applied. Vova wants to complete this as fast as possible, as the Petya may get back at any moment. He asks you to add the least possible number of operation records to the current log. Note that arbitrary number of operations may be added at the beginning, between any two other operations, or at the end of the log.
Input
The first line of the input contains the only integer n (1 ≤ n ≤ 100 000) — the number of the records left in Petya's journal.
Each of the following n lines describe the records in the current log in the order they are applied. Format described in the statement is used. All numbers in the input are integers not exceeding 109 by their absolute value.
Output
The first line of the output should contain a single integer m — the minimum possible number of records in the modified sequence of operations.
Next m lines should contain the corrected sequence of records following the format of the input (described in the statement), one per line and in the order they are applied. All the numbers in the output should be integers not exceeding 109 by their absolute value.
Note that the input sequence of operations must be the subsequence of the output sequence.
It's guaranteed that there exists the correct answer consisting of no more than 1 000 000 operations.
Examples
Input
2
insert 3
getMin 4
Output
4
insert 3
removeMin
insert 4
getMin 4
Input
4
insert 1
insert 1
removeMin
getMin 2
Output
6
insert 1
insert 1
removeMin
removeMin
insert 2
getMin 2
Note
In the first sample, after number 3 is inserted into the heap, the minimum number is 3. To make the result of the first getMin equal to 4 one should firstly remove number 3 from the heap and then add number 4 into the heap.
In the second sample case number 1 is inserted two times, so should be similarly removed twice.
题目大意:题干真他喵的长,读起来很难受,题目大意是这样的,给出n个操作语句,来模拟最小堆的三种操作:
#include
#include
#include
using namespace std;
char a[200005][250];
int xx[200005];
int main()
{
int n;
while(~scanf("%d",&n))
{
priority_queue,greater >s;
memset(xx,0,sizeof(xx));
for(int i=0;i0)
{
s.pop();
output++;
}
else
{
output++;output++;
}
}
if(op[0]=='g')
{
int flag=0;
while(!s.empty())
{
int now=s.top();
if(now==x)
{
//s.pop();
output++;
flag=1;
}
if(now>x)
{
output++;
s.push(x);
output++;
flag=1;
}
if(now0)
{
s.pop();
printf("removeMin\n");
}
else
{
printf("insert 0\n");
printf("removeMin\n");
}
}
if(op[0]=='g')
{
int flag=0;
while(!s.empty())
{
int now=s.top();
if(now==x)
{
// s.pop();
printf("getMin %d\n",x);
flag=1;
}
if(now>x)
{
printf("insert %d\n",x);
s.push(x);
printf("getMin %d\n",x);
flag=1;
}
if(now