Print in a single line two integers ― the minimum and the maximum number of rounds that Sereja could have missed.
Sample test(s) input3 2 2 1 2 2output
0 0input
9 3 1 2 3 2 8 1 4 5output
2 3input
10 0output
5 9Note
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
贪心做的。
//15 ms 0 KB #include#include int vis[4007]; int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { memset(vis,0,sizeof(vis)); for(int i=1;i<=m;i++) { int num,a,b; scanf("%d",&num); if(num==1) { scanf("%d%d",&a,&b); vis[a]=1; vis[b]=1; } else if(num==2) { scanf("%d",&a); vis[a]=1; } } int count1=0,count2=0,flag=0; for(int i=1;i
C. Team time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputNow it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.
For each team Olympiad, Vanya takes his play cards with numbers. He takes only the cards containing numbers 1 and 0. The boys are very superstitious. They think that they can do well at the Olympiad if they begin with laying all the cards in a row so that:
- there wouldn't be a pair of any side-adjacent cards with zeroes in a row;
- there wouldn't be a group of three consecutive cards containing numbers one.
Today Vanya brought n cards with zeroes and m cards with numbers one. The number of cards was so much that the friends do not know how to put all those cards in the described way. Help them find the required arrangement of the cards or else tell the guys that it is impossible to arrange cards in such a way.
InputThe first line contains two integers: n (1 ≤ n ≤ 106) ― the number of cards containing number 0; m (1 ≤ m ≤ 106) ― the number of cards containing number 1.
OutputIn a single line print the required sequence of zeroes and ones without any spaces. If such sequence is impossible to obtain, print -1.
Sample test(s) input1 2output101input4 8output110110110101input4 10output11011011011011input1 5output-1求前导0,110,10,和后导1的个数。//109 ms 0 KB #includeusing namespace std; int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { if(n>m+1||(n+1)*2 =0&&y>=0)goto there;//如果满足条件直接跳出 } there: for(int i=0;i