QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882241#10053. Post Officeguleng2007#25 416ms25192kbC++201.9kb2025-02-04 22:36:302025-02-04 22:36:30

Judging History

This is the latest submission verdict.

  • [2025-02-04 22:36:30]
  • Judged
  • Verdict: 25
  • Time: 416ms
  • Memory: 25192kb
  • [2025-02-04 22:36:30]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

const int N=2e5+5;

int p[N], a[N], b[N], dist[N], n, m;

namespace first
{
	vector <int> vec[N];

	void work()
	{
		memset(dist,0x3f,sizeof(dist));
		for(int i=1;i<=m;i++)
		{
			int x=a[i], y=b[i];
			for(int j=0;j<=n;j++)
			{
				if(x==y)
				{
					dist[i]=j;
					break;
				}

				x=p[x];
			}
		}

		for(int i=1;i<=m;i++)
			if(dist[i]==0x3f3f3f3f)
			{
				printf("-1\n");
				return;
			}

		for(int i=1;i<=n+m+2;i++)
		{
			bool can=true;
			for(int i=1;i<=m;i++)
				if(dist[i])
					can=false;

			if(can)
			{
				printf("%d\n",i-1);
				return;
			}

			for(int i=1;i<=n;i++)
				vec[i].clear();

			for(int j=1;j<=m;j++)
				if(dist[j])
					vec[a[j]].push_back(j);

			for(int i=1;i<=n;i++)
			{
				int Max=0, point=0;
				for(auto x:vec[i])
					if(dist[x]>Max)
						Max=dist[x], point=x;

				if(a[point]!=b[point])
					a[point]=p[a[point]], dist[point]--;
			}
		}
	}
}

namespace second
{
	vector <int> vec[N*2];

	bool check(int k)
	{
		for(int i=1;i<=n+m+1;i++)
			vec[i].clear();

		for(int i=1;i<=m;i++)
		{
			if(a[i]>b[i]+k)
				return false;
		
			vec[min(n+m+1,b[i]+k)].push_back(a[i]);
		}

		priority_queue <int> q;
		for(int i=n+m+1;i>=1;i--)
		{
			for(auto x:vec[i])
				q.push(x);

			if(q.size())
			{
				int x=q.top();
				q.pop();
				if(x>i)
					return false;
			}
		}

		if(q.size())
			return false;
		return true;
	}

	void work()
	{
		int l=0, r=n+m+1, ans=-1;
		while(l<=r)
		{
			int mid=(l+r)/2;
			if(check(mid))
				ans=mid, r=mid-1;
			else
				l=mid+1;
		}
		printf("%d\n",ans);
	}
}

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);

	cin >> m;
	for(int i=1;i<=m;i++)
		scanf("%d %d",&a[i],&b[i]);

	if(n<=3000 && m<=3000)
		first::work();
	else
		second::work();
	return 0;
}

详细

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 6ms
memory: 8016kb

input:

3000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

1119

result:

ok single line: '1119'

Test #2:

score: 3
Accepted
time: 4ms
memory: 5784kb

input:

3000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

774

result:

ok single line: '774'

Test #3:

score: 3
Accepted
time: 0ms
memory: 8028kb

input:

3000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

-1

result:

ok single line: '-1'

Test #4:

score: 3
Accepted
time: 1ms
memory: 8016kb

input:

3000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

-1

result:

ok single line: '-1'

Test #5:

score: 3
Accepted
time: 1ms
memory: 7880kb

input:

3000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

-1

result:

ok single line: '-1'

Test #6:

score: 3
Accepted
time: 0ms
memory: 8016kb

input:

3000
1 1 1 2 4 4 5 7 7 5 4 11 6 7 6 12 5 6 9 14 16 11 18 1 18 11 16 8 6 28 10 6 30 33 30 1 11 21 36 21 31 35 14 40 26 35 26 24 21 20 3 15 43 36 20 37 33 14 14 46 12 1 38 1 29 57 10 24 4 34 67 29 37 37 73 47 34 32 29 65 48 21 39 24 75 51 75 85 11 27 69 83 32 41 67 32 62 42 10 73 87 2 88 29 81 71 41 2...

output:

-1

result:

ok single line: '-1'

Test #7:

score: 3
Accepted
time: 1ms
memory: 8008kb

input:

3000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

-1

result:

ok single line: '-1'

Subtask #2:

score: 9
Accepted

Test #8:

score: 9
Accepted
time: 1ms
memory: 8012kb

input:

5
2 1 1 3 1
5
1 2
4 1
5 1
3 1
4 1

output:

3

result:

ok single line: '3'

Test #9:

score: 9
Accepted
time: 1ms
memory: 8012kb

input:

5
2 1 2 3 3
5
3 2
5 2
5 1
4 2
2 1

output:

4

result:

ok single line: '4'

Test #10:

score: 9
Accepted
time: 0ms
memory: 8020kb

input:

5
2 1 1 2 4
5
5 1
4 1
3 2
5 2
4 2

output:

4

result:

ok single line: '4'

Test #11:

score: 9
Accepted
time: 0ms
memory: 8016kb

input:

5
2 1 1 1 1
5
1 2
3 1
2 1
4 2
2 1

output:

2

result:

ok single line: '2'

Test #12:

score: 9
Accepted
time: 2ms
memory: 8008kb

input:

5
2 1 1 2 4
5
3 1
5 2
1 2
3 1
4 2

output:

2

result:

ok single line: '2'

Test #13:

score: 9
Accepted
time: 0ms
memory: 5964kb

input:

5
2 1 1 1 2
5
5 2
3 2
3 1
5 2
2 1

output:

2

result:

ok single line: '2'

Test #14:

score: 9
Accepted
time: 1ms
memory: 7844kb

input:

5
2 1 2 2 4
5
2 1
5 2
3 2
5 1
2 1

output:

3

result:

ok single line: '3'

Test #15:

score: 9
Accepted
time: 1ms
memory: 5832kb

input:

5
2 1 2 3 4
5
4 1
5 2
5 2
3 1
1 2

output:

4

result:

ok single line: '4'

Test #16:

score: 9
Accepted
time: 0ms
memory: 7892kb

input:

10
2 3 4 5 1 1 1 4 6 2
10
4 2
1 4
6 2
3 1
4 3
10 4
7 3
5 3
6 2
7 1

output:

7

result:

ok single line: '7'

Test #17:

score: 9
Accepted
time: 0ms
memory: 5964kb

input:

10
2 3 4 5 1 2 6 5 8 1
10
3 4
10 2
4 1
6 2
10 4
4 1
7 1
5 1
10 3
1 3

output:

6

result:

ok single line: '6'

Test #18:

score: 9
Accepted
time: 1ms
memory: 5960kb

input:

10
2 3 4 5 1 5 3 5 5 8
10
5 3
10 3
8 5
9 4
2 4
4 3
3 4
1 4
10 4
6 1

output:

7

result:

ok single line: '7'

Test #19:

score: 9
Accepted
time: 0ms
memory: 5760kb

input:

10
2 3 4 5 1 2 5 6 4 7
10
7 5
10 1
3 2
1 5
3 1
10 3
4 1
3 5
1 5
7 4

output:

7

result:

ok single line: '7'

Test #20:

score: 9
Accepted
time: 1ms
memory: 5964kb

input:

10
2 3 4 5 1 4 3 5 2 5
10
7 4
5 2
10 5
6 5
6 5
8 5
8 3
3 4
4 2
9 5

output:

4

result:

ok single line: '4'

Test #21:

score: 9
Accepted
time: 45ms
memory: 7972kb

input:

3000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

1563

result:

ok single line: '1563'

Test #22:

score: 9
Accepted
time: 45ms
memory: 8144kb

input:

3000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

1547

result:

ok single line: '1547'

Test #23:

score: 9
Accepted
time: 47ms
memory: 6096kb

input:

3000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

1574

result:

ok single line: '1574'

Test #24:

score: 9
Accepted
time: 0ms
memory: 5964kb

input:

5
2 1 1 1 1
5
1 2
3 1
2 1
5 4
2 1

output:

-1

result:

ok single line: '-1'

Test #25:

score: 9
Accepted
time: 0ms
memory: 5968kb

input:

10
2 3 4 5 1 7 8 9 10 6
10
3 5
3 5
1 5
3 4
5 3
10 6
4 6
6 7
9 10
2 1

output:

-1

result:

ok single line: '-1'

Test #26:

score: 9
Accepted
time: 1ms
memory: 8024kb

input:

3000
1 1 1 3 3 4 4 7 7 8 5 7 1 4 3 15 15 11 2 18 9 7 2 23 3 17 14 10 18 1 28 20 25 33 28 11 21 6 2 3 36 2 41 6 28 26 7 12 26 48 6 37 28 42 21 27 47 21 46 23 54 34 29 2 49 63 31 47 39 39 47 37 69 59 9 65 62 37 64 24 47 13 6 19 31 84 59 40 5 9 45 34 11 43 5 78 93 70 38 2 94 5 97 53 43 94 47 32 69 17 3...

output:

-1

result:

ok single line: '-1'

Test #27:

score: 9
Accepted
time: 3ms
memory: 8152kb

input:

3000
89 1 1 3 2 5 6 3 6 6 7 11 8 12 14 12 14 13 16 15 16 21 18 23 22 23 24 27 24 26 29 27 32 30 31 34 32 33 35 38 36 39 41 42 41 42 42 43 45 49 46 51 48 50 51 52 55 56 57 57 58 61 59 63 61 62 63 67 68 68 66 67 69 73 72 74 73 74 74 76 77 79 79 79 82 82 85 85 84 88 90 91 92 89 91 93 96 97 94 98 99 100...

output:

7

result:

ok single line: '7'

Test #28:

score: 9
Accepted
time: 2ms
memory: 8160kb

input:

3000
1699 1 1 3 2 4 5 3 2 4 9 7 5 13 10 12 12 10 11 16 18 19 21 18 18 23 22 26 22 26 23 31 27 29 28 28 29 33 31 35 34 34 36 38 39 39 45 41 43 46 49 50 48 53 54 53 54 54 54 57 55 61 56 63 57 65 60 64 62 68 69 70 65 73 69 73 76 73 73 73 79 75 75 77 81 85 86 87 87 89 88 85 92 86 93 92 90 92 95 94 96 98...

output:

7

result:

ok single line: '7'

Test #29:

score: 9
Accepted
time: 51ms
memory: 7960kb

input:

3000
89 1 1 3 2 5 6 3 6 6 7 11 8 12 14 12 14 13 16 15 16 21 18 23 22 23 24 27 24 26 29 27 32 30 31 34 32 33 35 38 36 39 41 42 41 42 42 43 45 49 46 51 48 50 51 52 55 56 57 57 58 61 59 63 61 62 63 67 68 68 66 67 69 73 72 74 73 74 74 76 77 79 79 79 82 82 85 85 84 88 90 91 92 89 91 93 96 97 94 98 99 100...

output:

3975

result:

ok single line: '3975'

Test #30:

score: 9
Accepted
time: 42ms
memory: 8032kb

input:

3000
1699 1 1 3 2 4 5 3 2 4 9 7 5 13 10 12 12 10 11 16 18 19 21 18 18 23 22 26 22 26 23 31 27 29 28 28 29 33 31 35 34 34 36 38 39 39 45 41 43 46 49 50 48 53 54 53 54 54 54 57 55 61 56 63 57 65 60 64 62 68 69 70 65 73 69 73 76 73 73 73 79 75 75 77 81 85 86 87 87 89 88 85 92 86 93 92 90 92 95 94 96 98...

output:

3631

result:

ok single line: '3631'

Test #31:

score: 9
Accepted
time: 1ms
memory: 8016kb

input:

3000
2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 92 91 94 93 96 95 98 97 100 99 102...

output:

9

result:

ok single line: '9'

Test #32:

score: 9
Accepted
time: 3ms
memory: 8140kb

input:

3000
89 1 1 3 2 5 6 3 6 6 7 11 8 12 14 12 14 13 16 15 16 21 18 23 22 23 24 27 24 26 29 27 32 30 31 34 32 33 35 38 36 39 41 42 41 42 42 43 45 49 46 51 48 50 51 52 55 56 57 57 58 61 59 63 61 62 63 67 68 68 66 67 69 73 72 74 73 74 74 76 77 79 79 79 82 82 85 85 84 88 90 91 92 89 91 93 96 97 94 98 99 100...

output:

13

result:

ok single line: '13'

Test #33:

score: 9
Accepted
time: 0ms
memory: 7964kb

input:

3000
1699 1 1 3 2 4 5 3 2 4 9 7 5 13 10 12 12 10 11 16 18 19 21 18 18 23 22 26 22 26 23 31 27 29 28 28 29 33 31 35 34 34 36 38 39 39 45 41 43 46 49 50 48 53 54 53 54 54 54 57 55 61 56 63 57 65 60 64 62 68 69 70 65 73 69 73 76 73 73 73 79 75 75 77 81 85 86 87 87 89 88 85 92 86 93 92 90 92 95 94 96 98...

output:

13

result:

ok single line: '13'

Subtask #3:

score: 13
Accepted

Test #34:

score: 13
Accepted
time: 91ms
memory: 22484kb

input:

2
1 1
200000
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1...

output:

200000

result:

ok single line: '200000'

Test #35:

score: 13
Accepted
time: 250ms
memory: 14164kb

input:

200000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

200000

result:

ok single line: '200000'

Test #36:

score: 13
Accepted
time: 416ms
memory: 19264kb

input:

200000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

200008

result:

ok single line: '200008'

Test #37:

score: 13
Accepted
time: 92ms
memory: 5960kb

input:

3000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

5998

result:

ok single line: '5998'

Test #38:

score: 13
Accepted
time: 105ms
memory: 23408kb

input:

200000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

399998

result:

ok single line: '399998'

Test #39:

score: 13
Accepted
time: 29ms
memory: 6088kb

input:

3000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

3000

result:

ok single line: '3000'

Test #40:

score: 13
Accepted
time: 219ms
memory: 24576kb

input:

200000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

200000

result:

ok single line: '200000'

Subtask #4:

score: 0
Wrong Answer

Test #41:

score: 25
Accepted
time: 142ms
memory: 19532kb

input:

200000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

199401

result:

ok single line: '199401'

Test #42:

score: 25
Accepted
time: 127ms
memory: 18848kb

input:

200000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

199604

result:

ok single line: '199604'

Test #43:

score: 25
Accepted
time: 4ms
memory: 5968kb

input:

3000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

-1

result:

ok single line: '-1'

Test #44:

score: 0
Wrong Answer
time: 160ms
memory: 19736kb

input:

200000
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

198944

result:

wrong answer 1st lines differ - expected: '-1', found: '198944'

Subtask #5:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 151ms
memory: 24712kb

input:

2
2 1
200000
2 1
2 1
1 2
2 1
1 2
1 2
2 1
1 2
1 2
2 1
2 1
1 2
2 1
2 1
1 2
1 2
2 1
1 2
1 2
2 1
2 1
1 2
1 2
1 2
2 1
2 1
2 1
2 1
1 2
2 1
2 1
2 1
1 2
2 1
1 2
1 2
1 2
1 2
2 1
2 1
2 1
2 1
1 2
2 1
1 2
1 2
1 2
2 1
1 2
1 2
1 2
1 2
2 1
2 1
2 1
1 2
1 2
1 2
2 1
2 1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
2 1
1 2
1 2
2 1
2 1...

output:

199998

result:

wrong answer 1st lines differ - expected: '100031', found: '199998'

Subtask #6:

score: 0
Wrong Answer

Test #60:

score: 0
Wrong Answer
time: 386ms
memory: 25192kb

input:

200000
1 1 1 3 3 2 5 3 4 6 9 3 3 9 14 13 4 2 18 9 3 11 20 13 7 13 14 6 13 2 22 14 5 9 19 7 28 22 10 37 37 26 15 39 18 31 18 19 22 6 4 22 29 30 43 38 33 39 19 10 14 25 35 5 3 50 34 13 60 44 31 47 67 27 52 26 48 30 18 63 76 80 49 16 39 16 59 77 60 26 84 50 54 36 75 77 72 77 1 45 13 20 86 19 56 9 47 82...

output:

200639

result:

wrong answer 1st lines differ - expected: '119708', found: '200639'

Subtask #7:

score: 0
Wrong Answer

Test #97:

score: 0
Wrong Answer
time: 162ms
memory: 15032kb

input:

200000
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

199859

result:

wrong answer 1st lines differ - expected: '100667', found: '199859'