QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#720802#9563. 人间应又雪chenxinyang200670 427ms6360kbC++203.1kb2024-11-07 14:11:122024-11-07 14:11:14

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 14:11:14]
  • 评测
  • 测评结果:70
  • 用时:427ms
  • 内存:6360kb
  • [2024-11-07 14:11:12]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}


/*ll power(ll p,int k = mod - 2){
	ll ans = 1;
	while(k){
		if(k % 2 == 1) ans = ans * p % mod;
		p = p * p % mod;
		k /= 2;	
	}
	return ans;
}*/
int T,testid;
int n,m,c;
int a[100005];

struct ds{
	#define lowbit(x) (x & (-x))
	int tree[100005],bas;
	void init(){
		bas = 0;
		rep(i,1,m) tree[i] = lowbit(i);
	}
	void upd(int pos,int C){
		while(pos <= m){
			tree[pos] += C;
			pos += lowbit(pos);
		}
	}
	int qry(int pos){
		int ret = 0;
		while(pos){
			ret += tree[pos];
			pos -= lowbit(pos);
		}
		return ret;
	}
	int kth(int k){
		int pos = 0;
		per(_k,__lg(m),0){
			if(pos + (1 << _k) <= m && k > tree[pos + (1 << _k)]){
				pos += 1 << _k;
				k -= tree[pos];
			}
		}
		return pos + 1;
	}
	void rmv(int pos){
		upd(pos,-1);
		bas++;
	}
	int del(int k){
		if(bas >= k) return 0;
		int pos = kth(k - bas);
		rmv(pos);
		return pos;
	}
	int eval(int p){
		return bas + qry(p);
	}
}pst,nxt;

vector <int> S;
void eval(int V,int *idx,int *res){
	pst.init();nxt.init();
	fill(idx,idx + V + 1,n + 1);
	fill(res,res + V + 1,0);
	int p = V;
	rep(i,1,n){
		int cur = a[i];
		while(1){
			int pos = nxt.del(cur);
			if(!pos) break;
//			printf("%d del %d\n",i,pos);
			S.eb(pos);
			cur -= c;
		}
		while(p >= 0 && nxt.eval(p) > V){
//			printf("%d->%d\n",p,nxt.eval(p));
			idx[p] = i;
			res[p] = V - pst.eval(p);
			p--;
		}
		for(int v:S) pst.rmv(v);
		S.clear();
	}
/*	rep(i,0,V) printf("%d ",idx[i]);
	printf("\n");
	rep(i,0,V) printf("%d ",res[i]);
	printf("\n");	*/
}

int idx[2][100005],res[2][100005];
int check(int V){
	eval(V,idx[0],res[0]);
	reverse(a + 1,a + n + 1);
	eval(V,idx[1],res[1]);
	rep(i,0,V) idx[1][i] = n + 1 - idx[1][i];
	reverse(a + 1,a + n + 1);

	rep(i,0,V){
		if(idx[0][i] > idx[1][V - i]) return 1;
		assert(idx[0][i] >= 1 && idx[0][i] <= n + 1);
		assert(idx[1][i] >= 0 && idx[1][i] <= n);
		if(idx[0][i] == idx[1][V - i] && 1ll * c * (res[0][i] + res[1][V - i]) + V >= a[idx[0][i]]) return 1;
	}
	return 0;
}

void solve(){
	scanf("%d%d%d",&n,&m,&c);
	rep(i,1,n) scanf("%d",&a[i]);

	int answer = m;
	per(k,20,0) if(answer >= (1 << k) && check(answer - (1 << k))) answer -= 1 << k;
	printf("%d\n",answer);
//	check(2);
}

int main(){
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	scanf("%d%d",&T,&testid);
	while(T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 2
Accepted
time: 0ms
memory: 5812kb

input:

1000 1
9 8 0
8 5 2 1 6 4 5 1 5
9 8 0
1 7 3 2 0 8 5 1 0
8 9 0
3 8 7 3 2 4 9 9
8 9 0
8 3 9 3 9 8 3 4
9 10 0
0 9 5 5 4 3 6 10 5
8 8 0
3 5 1 6 8 4 2 5
8 9 0
5 2 3 8 1 4 2 9
10 8 0
2 8 2 3 1 7 0 1 5 1
8 9 0
1 0 4 9 9 5 7 2
9 10 0
3 4 0 10 0 9 6 7 0
8 9 0
4 8 4 4 0 4 2 3
9 8 0
0 5 2 3 1 0 4 0 0
10 10 0
3 ...

output:

8
8
9
9
10
8
9
8
9
10
8
5
10
9
8
8
7
10
8
10
8
10
9
8
10
6
10
8
8
6
7
8
9
7
9
8
8
8
5
8
9
10
5
8
10
8
10
7
9
9
9
8
8
7
9
9
8
9
8
8
7
8
8
7
10
9
10
9
9
8
8
9
7
8
9
7
7
9
6
10
8
7
8
8
9
9
9
9
9
8
8
5
7
8
8
9
6
8
8
9
8
9
8
9
9
10
8
9
8
8
7
8
7
8
7
7
7
10
9
10
9
9
8
9
8
10
10
8
7
10
8
10
8
8
8
7
10
10
8...

result:

ok 1000 lines

Test #2:

score: 0
Runtime Error

input:

2 1
499998 499999 0
301138 174092 254294 217002 447568 498904 49075 373725 308244 252462 370947 392908 319430 488362 86682 68848 435192 169516 29640 369208 128139 213960 159766 44498 322235 240582 283451 176399 270410 120552 173820 121114 197080 354767 283489 398040 13031 432699 251631 352577 264788...

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #3:

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

input:

1000 2
10 2 3
1 2 1 2 1 2 2 1 0 1
10 2 0
0 0 0 0 0 0 0 0 0 0
10 2 3
0 0 1 1 0 1 0 0 0 1
10 2 3
0 0 0 0 0 0 0 0 0 0
10 2 1
1 0 2 2 0 0 1 0 1 1
10 2 3
0 1 1 0 2 0 1 2 2 2
10 2 0
0 0 0 0 0 0 0 0 0 0
10 2 0
0 0 0 1 1 1 0 0 0 1
10 2 1
1 1 0 2 0 0 0 0 0 0
10 2 1
1 1 2 0 0 2 0 2 1 0
10 2 1
0 0 0 0 0 0 0 0 ...

output:

2
0
1
0
2
2
0
1
1
2
0
1
0
1
0
0
2
2
0
0
2
0
1
2
1
1
2
0
2
1
0
0
2
1
0
1
2
1
0
1
2
2
2
0
1
2
1
2
2
2
1
2
2
2
1
0
1
2
2
1
0
1
0
1
0
2
2
2
2
2
0
1
2
2
2
2
1
2
2
1
2
0
0
1
2
2
1
2
2
1
0
2
2
2
1
0
0
0
1
2
0
2
2
0
0
2
2
0
2
2
0
1
1
2
0
0
1
2
1
2
1
2
2
2
1
1
2
0
0
2
2
0
2
2
2
0
2
1
1
0
2
2
2
2
0
0
1
0
0
1
...

result:

ok 1000 lines

Test #4:

score: 3
Accepted
time: 5ms
memory: 3976kb

input:

100 2
1000 2 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

0
1
1
2
1
0
1
1
2
0
0
0
0
0
0
1
0
2
2
2
1
2
1
1
1
2
2
2
0
2
1
1
2
0
0
1
2
0
0
0
0
2
2
2
1
1
2
2
0
0
2
1
2
1
2
2
0
2
0
0
0
2
2
0
2
0
0
2
1
2
1
2
0
1
0
2
1
1
2
2
2
2
2
2
0
2
2
1
2
2
0
1
2
1
1
0
0
0
0
2

result:

ok 100 lines

Test #5:

score: 0
Wrong Answer
time: 4ms
memory: 4188kb

input:

2 2
500000 2 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

0
0

result:

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

Subtask #3:

score: 5
Accepted

Test #6:

score: 5
Accepted
time: 1ms
memory: 5848kb

input:

10 3
5 5 3
4 1 5 1 4
4 5 4
2 2 3 4
5 5 0
1 1 5 3 4
4 4 2
2 1 0 1
3 5 3
0 2 3
5 4 2
3 2 4 1 4
3 4 4
3 2 2
3 4 5
4 0 2
3 5 3
1 0 5
5 4 0
2 0 4 1 3

output:

3
2
5
1
2
3
2
2
2
4

result:

ok 10 lines

Test #7:

score: 5
Accepted
time: 1ms
memory: 6008kb

input:

10 3
5 5 4
2 2 1 0 0
5 5 5
5 3 1 0 1
5 5 5
0 3 2 0 0
5 5 1
1 5 2 5 2
5 5 3
4 5 0 1 5
5 5 5
2 3 3 4 3
5 5 4
5 4 5 2 5
5 5 1
3 0 2 2 3
5 5 5
1 3 1 1 4
5 5 3
1 3 4 5 1

output:

2
2
2
4
3
3
4
2
2
3

result:

ok 10 lines

Test #8:

score: 5
Accepted
time: 1ms
memory: 5924kb

input:

10 3
5 5 4
1 5 2 2 1
5 5 5
0 1 1 1 4
5 5 2
1 1 2 3 4
5 5 3
1 3 5 4 2
5 5 5
1 1 5 4 3
5 5 5
0 3 4 4 5
5 5 1
0 0 1 2 5
5 5 3
0 0 1 2 4
5 5 3
3 5 3 3 3
5 5 4
2 5 5 4 3

output:

2
1
3
3
3
3
3
2
3
4

result:

ok 10 lines

Test #9:

score: 5
Accepted
time: 0ms
memory: 3916kb

input:

10 3
5 5 5
5 3 2 1 1
5 5 4
3 3 1 2 2
5 5 4
5 5 4 0 1
5 5 4
5 4 4 0 0
5 5 4
5 3 3 1 0
5 5 1
4 2 2 3 4
5 5 2
4 3 3 2 1
5 5 3
5 2 2 1 1
5 5 3
5 4 3 3 0
5 5 4
5 1 1 2 4

output:

2
2
3
3
3
3
3
2
3
2

result:

ok 10 lines

Test #10:

score: 5
Accepted
time: 0ms
memory: 3912kb

input:

10 3
5 5 2
4 2 4 4 5
5 5 1
2 0 2 3 4
5 5 2
2 5 4 1 1
5 5 3
1 5 5 5 5
5 5 5
5 1 1 5 3
5 5 5
3 3 5 1 5
5 5 1
3 4 1 3 2
5 5 5
5 5 5 2 2
5 5 4
5 5 1 1 5
5 5 5
5 5 2 2 5

output:

4
3
3
4
3
3
3
3
3
3

result:

ok 10 lines

Test #11:

score: 5
Accepted
time: 0ms
memory: 3820kb

input:

10 3
5 5 1
5 5 3 5 1
5 5 3
0 0 4 1 1
5 5 5
5 1 1 1 1
5 5 4
5 1 1 5 0
5 5 1
0 2 1 5 5
5 5 5
1 1 5 1 1
5 5 3
2 5 0 0 0
5 5 1
3 3 5 0 0
5 5 3
2 2 5 4 0
5 5 5
0 5 1 1 1

output:

4
1
1
2
4
2
2
3
2
1

result:

ok 10 lines

Test #12:

score: 5
Accepted
time: 0ms
memory: 3980kb

input:

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

output:

4
5
4
4
4
4
4
4
5
4

result:

ok 10 lines

Subtask #4:

score: 10
Accepted

Dependency #3:

100%
Accepted

Test #13:

score: 10
Accepted
time: 0ms
memory: 3900kb

input:

20 4
9 10 9
10 4 9 10 0 4 9 10 8
9 9 1
8 7 3 6 1 8 6 3 9
10 8 4
3 3 4 4 8 4 7 0 0 0
9 8 9
5 1 3 6 6 2 2 6 3
8 8 5
6 0 4 1 4 0 4 4
8 10 8
5 7 6 5 6 1 8 7
10 10 1
5 4 5 4 0 4 10 9 7 8
8 9 9
2 3 0 5 2 1 5 1
8 10 5
10 8 9 9 2 10 1 10
9 10 3
3 4 3 6 7 3 5 1 5
8 8 10
1 0 2 0 0 0 7 5
9 8 9
2 4 8 6 4 4 5 1 ...

output:

6
7
4
5
4
6
8
3
7
5
2
5
5
6
4
5
5
6
4
5

result:

ok 20 lines

Test #14:

score: 10
Accepted
time: 0ms
memory: 3784kb

input:

4 4
50 50 2
27 29 4 40 18 13 32 22 48 50 46 38 9 45 3 22 41 35 24 33 23 15 11 1 39 2 33 44 20 22 35 17 26 31 35 49 21 22 13 46 30 3 44 21 40 1 28 3 50 5
50 50 1
6 15 26 15 20 9 43 13 17 17 44 19 10 44 48 15 20 32 22 6 38 5 33 37 26 23 50 17 19 15 18 35 39 32 12 36 50 0 1 39 23 46 43 12 8 0 48 28 46 ...

output:

45
48
45
46

result:

ok 4 lines

Test #15:

score: 10
Accepted
time: 1ms
memory: 5856kb

input:

4 4
50 50 27
0 2 2 3 3 5 6 6 6 6 6 7 7 7 10 12 13 14 16 19 21 21 22 23 24 25 26 49 49 49 49 48 48 45 42 41 40 39 38 37 36 36 36 35 34 34 33 33 33 32
50 50 8
1 3 4 4 5 7 7 7 8 9 10 10 11 12 12 13 14 15 15 16 18 19 20 22 23 25 25 26 27 28 29 30 30 30 32 32 34 36 36 36 37 41 41 41 42 43 43 43 45 47
50 ...

output:

26
34
41
32

result:

ok 4 lines

Test #16:

score: 10
Accepted
time: 0ms
memory: 3904kb

input:

4 4
50 50 16
49 47 45 45 42 41 40 40 39 39 0 1 1 1 2 2 4 5 6 10 12 13 14 16 16 18 18 18 19 20 24 26 26 26 27 27 30 31 32 32 33 34 34 35 35 36 36 38 38 38
50 50 10
49 48 47 44 42 42 42 41 41 40 40 38 36 34 34 33 32 31 31 29 28 28 27 27 26 26 25 25 23 21 19 18 16 16 16 15 14 14 0 2 4 4 6 6 7 7 7 8 11 ...

output:

31
34
35
31

result:

ok 4 lines

Test #17:

score: 10
Accepted
time: 0ms
memory: 3932kb

input:

4 4
50 50 18
16 34 15 50 15 34 16 16 16 16 35 17 35 16 16 16 50 36 18 18 18 36 36 18 50 35 17 50 16 34 15 15 15 15 15 34 34 15 15 15 15 15 50 34 35 35 50 32 32 14
50 50 2
6 6 8 5 5 5 5 5 5 5 5 5 5 5 5 5 8 6 6 6 6 6 6 9 7 7 7 7 7 7 11 8 6 6 6 8 7 4 4 4 4 4 4 4 4 4 4 6 3 3
50 50 6
0 0 0 0 0 0 0 0 7 1 ...

output:

29
9
1
38

result:

ok 4 lines

Test #18:

score: 10
Accepted
time: 0ms
memory: 3892kb

input:

4 4
50 50 2
6 6 6 12 8 8 8 8 8 8 8 8 8 13 8 8 8 18 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
50 50 18
5 5 5 5 5 5 5 5 5 5 50 23 23 23 23 23 23 23 23 23 23 23 23 23 23 50 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26
50 50 1
14 14 14 14 14 14 14 14 14 1...

output:

9
26
17
30

result:

ok 4 lines

Test #19:

score: 10
Accepted
time: 0ms
memory: 3892kb

input:

4 4
50 50 46
49 50 49 50 50 50 49 50 49 50 49 49 49 50 49 50 49 50 49 50 50 50 50 50 49 50 50 50 49 49 49 50 49 49 49 50 49 49 50 49 49 50 50 50 50 49 50 49 50 49
50 50 11
50 50 49 50 50 49 49 49 50 49 50 49 50 49 50 50 49 50 50 49 50 50 49 49 50 50 50 49 49 49 49 49 49 49 49 49 49 49 50 49 49 50 49...

output:

49
50
49
49

result:

ok 4 lines

Subtask #5:

score: 10
Accepted

Dependency #4:

100%
Accepted

Test #20:

score: 10
Accepted
time: 1ms
memory: 5904kb

input:

30 5
20 18 2
11 1 4 8 18 16 15 13 13 10 3 4 5 9 10 11 2 4 4 8
19 20 0
6 17 17 15 3 16 2 8 7 11 0 14 14 6 12 15 19 2 9
19 20 10
19 10 0 7 14 8 5 7 20 4 10 16 9 3 5 10 12 4 3
18 20 4
8 9 17 0 1 15 15 4 12 13 10 12 8 17 17 16 18 6
19 18 10
17 1 17 10 0 5 13 5 16 12 8 18 0 8 12 12 5 3 9
20 19 3
16 6 17 ...

output:

13
19
10
13
11
15
15
14
15
13
10
11
18
20
13
11
12
10
11
20
10
12
14
12
18
15
13
14
11
11

result:

ok 30 lines

Test #21:

score: 10
Accepted
time: 1ms
memory: 3828kb

input:

3 5
200 200 18
76 132 130 37 139 121 171 152 22 23 194 5 181 174 96 3 71 109 143 20 144 114 157 195 109 99 120 132 110 50 101 103 37 186 71 193 157 22 65 136 84 96 123 13 154 26 66 161 200 60 93 45 48 137 18 81 77 45 37 145 100 57 130 54 20 38 28 135 16 132 85 6 18 117 26 129 57 172 10 7 198 152 26 ...

output:

157
135
131

result:

ok 3 lines

Test #22:

score: 10
Accepted
time: 1ms
memory: 3912kb

input:

2 5
300 300 52
0 1 2 2 4 6 7 7 9 10 10 11 12 12 12 13 14 14 17 18 21 21 23 24 24 24 24 24 24 26 26 26 27 29 32 32 33 33 36 37 37 39 39 40 40 40 41 42 43 44 45 46 46 47 47 47 50 50 51 53 54 54 57 57 57 60 65 65 66 71 72 72 74 74 74 74 75 75 75 78 80 81 81 81 82 82 83 83 84 85 86 91 91 93 93 94 94 94 ...

output:

217
189

result:

ok 2 lines

Test #23:

score: 10
Accepted
time: 1ms
memory: 3980kb

input:

2 5
300 300 2
300 299 299 299 299 298 298 297 289 289 288 288 286 286 286 286 285 284 283 282 280 279 279 278 278 278 276 275 275 275 275 274 274 273 273 272 271 270 270 270 266 265 264 262 261 260 259 257 257 256 256 254 254 251 249 249 245 244 244 244 240 236 236 236 234 233 233 227 227 227 226 22...

output:

289
204

result:

ok 2 lines

Test #24:

score: 10
Accepted
time: 1ms
memory: 5812kb

input:

2 5
300 300 12
46 34 34 34 34 47 35 35 48 49 37 61 35 35 35 35 35 35 47 34 47 35 35 48 36 36 36 36 36 36 36 36 49 37 50 38 38 38 38 38 38 38 38 38 38 38 38 38 38 51 39 39 39 39 39 39 52 40 40 40 40 40 40 40 53 41 41 41 41 41 41 41 41 66 41 54 42 42 42 54 41 41 53 40 40 40 40 53 54 55 55 42 42 42 42 ...

output:

59
172

result:

ok 2 lines

Test #25:

score: 10
Accepted
time: 0ms
memory: 3840kb

input:

2 5
300 300 39
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 132 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14...

output:

15
2

result:

ok 2 lines

Test #26:

score: 10
Accepted
time: 1ms
memory: 5892kb

input:

2 5
300 300 82
300 299 300 299 299 299 300 299 300 299 300 299 299 299 300 299 299 300 299 299 300 300 300 300 300 299 300 299 300 299 299 300 299 299 300 300 300 299 300 299 300 300 300 300 299 300 299 300 299 300 300 299 299 300 300 299 300 300 300 299 299 300 299 300 299 300 299 300 300 300 299 2...

output:

300
299

result:

ok 2 lines

Subtask #6:

score: 10
Accepted

Dependency #5:

100%
Accepted

Test #27:

score: 10
Accepted
time: 0ms
memory: 3784kb

input:

40 6
100 100 55
21 89 57 40 63 86 81 67 27 21 93 86 92 67 55 18 98 31 76 24 54 92 84 57 40 19 65 57 8 54 3 11 77 72 43 23 41 77 28 49 95 77 92 11 53 34 7 47 48 96 14 35 46 92 14 28 14 11 79 29 15 45 84 22 39 24 83 58 36 16 69 45 25 60 95 79 72 85 69 50 28 43 10 80 70 73 69 22 20 87 30 25 45 4 81 0 2...

output:

55
68
55
60
51
77
62
88
66
59
67
58
55
55
54
75
71
69
68
88
55
55
56
56
53
60
57
57
54
58
61
53
71
70
56
51
86
69
56
52

result:

ok 40 lines

Test #28:

score: 10
Accepted
time: 7ms
memory: 3832kb

input:

2 6
2000 2000 62
2 2 4 4 5 7 7 8 8 9 11 11 13 13 13 14 14 18 19 19 20 21 22 24 25 25 27 27 27 28 29 30 30 31 32 33 34 34 37 37 40 40 42 44 45 46 47 48 49 52 58 59 60 61 61 62 62 64 65 65 65 65 65 66 66 67 67 69 70 71 72 72 73 74 74 75 75 78 80 80 81 81 83 84 84 84 88 89 90 90 91 94 94 96 96 98 98 98...

output:

1837
1609

result:

ok 2 lines

Test #29:

score: 10
Accepted
time: 7ms
memory: 5924kb

input:

2 6
2000 2000 471
2000 1997 1997 1996 1996 1992 1992 1992 1990 1989 1988 1988 1987 1985 1984 1981 1979 1978 1977 1977 1977 1976 1976 1973 1973 1972 1972 1971 1970 1968 1968 1967 1966 1963 1962 1961 1958 1957 1956 1955 1954 1953 1953 1952 1951 1951 1949 1949 1946 1945 1944 1944 1944 1942 1941 1939 19...

output:

1390
1559

result:

ok 2 lines

Test #30:

score: 10
Accepted
time: 5ms
memory: 3944kb

input:

2 6
2000 2000 169
955 1805 1130 1301 1132 1131 1131 962 962 962 1301 1132 1302 1132 1131 961 1130 1468 959 1297 957 1296 1126 956 1126 1127 1128 959 1299 1130 1129 1469 1132 1302 1302 963 963 963 1132 1131 1130 1636 1296 958 958 958 1128 959 1297 1297 1129 1129 1298 959 1129 1130 1299 959 959 959 95...

output:

1312
890

result:

ok 2 lines

Test #31:

score: 10
Accepted
time: 0ms
memory: 5800kb

input:

2 6
2000 2000 153
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 ...

output:

12
1488

result:

ok 2 lines

Test #32:

score: 10
Accepted
time: 8ms
memory: 4020kb

input:

2 6
2000 2000 1865
1999 1999 1999 1999 1999 1999 2000 1999 2000 1999 2000 1999 1999 1999 1999 1999 1999 1999 1999 1999 1999 1999 2000 1999 2000 2000 2000 1999 2000 1999 1999 1999 1999 1999 1999 2000 2000 2000 1999 2000 1999 2000 1999 2000 1999 2000 1999 2000 2000 2000 2000 1999 2000 1999 1999 2000 2...

output:

1999
1999

result:

ok 2 lines

Subtask #7:

score: 20
Accepted

Test #33:

score: 20
Accepted
time: 41ms
memory: 3836kb

input:

5000 7
19 19 16
4 12 5 15 12 11 9 0 3 1 8 4 17 2 19 3 5 4 1
18 20 19
18 14 12 16 7 14 2 3 13 4 4 6 8 1 16 19 10 20
20 19 3
15 7 5 16 19 0 1 19 10 19 13 17 18 5 1 13 9 4 8 15
19 20 6
8 3 0 12 4 13 19 2 6 4 11 8 17 6 8 13 11 8 20
18 19 19
3 15 19 12 17 11 11 2 4 4 16 13 10 12 15 14 3 10
19 20 20
12 15...

output:

9
10
16
11
11
12
13
12
14
12
10
19
10
9
12
18
10
15
11
9
9
11
9
11
9
11
10
9
18
12
16
11
10
18
9
10
9
14
12
17
9
13
15
11
10
13
11
11
13
11
13
10
9
9
14
10
10
11
12
10
14
12
11
13
10
12
9
13
18
13
11
16
13
15
10
10
13
10
11
12
9
11
11
11
11
18
12
10
10
11
19
11
9
16
11
10
10
10
17
9
16
10
12
10
12
1...

result:

ok 5000 lines

Test #34:

score: 20
Accepted
time: 44ms
memory: 3820kb

input:

5000 7
20 20 17
8 13 3 20 11 14 0 16 9 4 6 12 10 19 17 18 6 12 10 4
20 20 13
20 20 0 8 18 19 0 6 12 12 11 12 6 9 20 13 16 20 16 18
20 20 15
6 16 1 6 2 9 15 4 14 1 14 18 14 13 1 4 19 16 5 16
20 20 14
6 16 0 9 18 16 11 16 2 9 2 9 0 15 10 5 14 18 19 12
20 20 16
11 16 20 15 20 4 18 12 20 1 20 11 13 15 1...

output:

12
12
11
11
14
10
14
13
12
11
15
11
11
12
11
11
10
13
10
12
13
13
12
12
8
14
14
11
14
11
12
18
14
10
12
12
11
12
12
11
13
11
10
12
13
10
14
9
10
10
12
17
10
13
12
15
11
11
12
10
11
11
11
10
10
17
12
13
10
14
14
8
10
12
16
12
16
9
11
14
10
11
12
14
13
11
12
10
11
18
10
12
12
9
10
9
11
15
10
11
9
14
1...

result:

ok 5000 lines

Test #35:

score: 20
Accepted
time: 368ms
memory: 5288kb

input:

2 7
50000 50000 13
14372 18626 2882 156 873 21151 14082 1047 948 5262 23982 17851 3525 45524 36586 13870 5948 12786 22417 48991 16686 3022 26756 27407 35381 1439 1732 31854 48953 2459 28941 6550 19617 8044 43294 42701 20930 33877 11580 1246 1164 30125 6870 9257 20119 28306 13881 7577 5889 4194 5365 ...

output:

49950
49953

result:

ok 2 lines

Test #36:

score: 20
Accepted
time: 323ms
memory: 6360kb

input:

2 7
50000 50000 4
1 2 2 4 5 5 5 10 11 12 12 14 16 18 18 20 20 21 22 22 22 22 23 24 24 26 26 26 27 27 27 28 29 29 31 32 32 33 33 33 34 35 37 39 42 45 46 47 48 50 50 51 52 55 55 56 57 60 63 67 68 69 69 69 69 71 71 73 77 77 78 84 85 86 86 86 87 88 89 89 90 91 91 92 92 93 94 95 96 96 97 97 98 99 100 100...

output:

49964
49950

result:

ok 2 lines

Test #37:

score: 20
Accepted
time: 343ms
memory: 5256kb

input:

2 7
50000 50000 7
50000 49993 49993 49993 49992 49991 49991 49991 49990 49990 49988 49987 49987 49986 49985 49984 49983 49981 49980 49980 49979 49978 49978 49977 49977 49974 49973 49972 49971 49970 49969 49967 49966 49966 49966 49964 49963 49963 49962 49962 49960 49960 49960 49958 49957 49957 49957 ...

output:

49943
49862

result:

ok 2 lines

Test #38:

score: 20
Accepted
time: 80ms
memory: 4352kb

input:

5 7
20000 20000 8
6344 6335 6335 6352 6344 6336 6344 6335 6335 6335 6343 6334 6334 6334 6334 6334 6334 6352 6353 6345 6337 6337 6337 6337 6337 6345 6353 6353 6336 6336 6344 6335 6344 6336 6336 6336 6345 6337 6355 6339 6339 6339 6357 6357 6339 6339 6339 6339 6339 6339 6348 6340 6349 6357 6339 6339 63...

output:

6422
5411
650
7030
2477

result:

ok 5 lines

Test #39:

score: 20
Accepted
time: 130ms
memory: 4412kb

input:

5 7
20000 20000 2
1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 1251 12...

output:

9888
2710
14936
603
7797

result:

ok 5 lines

Test #40:

score: 20
Accepted
time: 360ms
memory: 5384kb

input:

2 7
50000 50000 8
50000 49999 49999 50000 50000 49999 50000 49999 50000 50000 49999 49999 49999 50000 50000 49999 50000 49999 49999 49999 50000 49999 49999 49999 50000 49999 49999 50000 50000 49999 49999 49999 49999 49999 49999 49999 49999 50000 50000 50000 50000 50000 50000 50000 50000 50000 49999 ...

output:

50000
50000

result:

ok 2 lines

Subtask #8:

score: 15
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #41:

score: 15
Accepted
time: 427ms
memory: 6316kb

input:

2 8
50000 50000 6673
19554 35986 42705 21899 31473 7560 39294 35870 541 16472 47245 23432 15909 47691 24301 46822 20982 2334 36820 13274 44584 26614 17600 27283 16933 25520 10643 30510 12571 332 11818 20945 12015 34688 39814 12779 38464 4671 33555 44413 3733 13075 16886 29885 435 9753 37882 40230 26...

output:

38283
38191

result:

ok 2 lines

Test #42:

score: 15
Accepted
time: 290ms
memory: 5180kb

input:

2 8
50000 50000 5694
0 0 1 3 5 7 9 9 9 12 15 15 17 20 21 21 23 24 28 30 33 35 38 39 39 40 41 42 43 44 45 46 47 47 49 49 49 49 51 52 52 53 54 55 56 56 56 57 59 62 62 64 65 65 66 66 67 68 69 69 70 70 72 73 76 78 79 80 81 81 82 82 82 83 87 88 88 91 91 91 92 92 94 94 95 95 97 98 98 98 100 102 102 103 10...

output:

39836
41092

result:

ok 2 lines

Test #43:

score: 15
Accepted
time: 311ms
memory: 5140kb

input:

2 8
50000 50000 8333
50000 49997 49996 49995 49995 49993 49992 49991 49991 49988 49982 49981 49981 49980 49979 49978 49978 49976 49976 49975 49971 49971 49970 49967 49967 49966 49964 49963 49963 49963 49962 49960 49960 49960 49959 49959 49957 49956 49956 49956 49956 49955 49955 49953 49952 49950 499...

output:

36762
39631

result:

ok 2 lines

Test #44:

score: 15
Accepted
time: 127ms
memory: 4192kb

input:

5 8
20000 20000 68
2416 2416 2416 2416 2484 2415 2483 2414 2414 2414 2483 2415 2484 2416 2485 2417 2485 2416 2485 2555 2419 2419 2487 2418 2418 2418 2418 2418 2418 2418 2418 2418 2486 2417 2417 2485 2484 2415 2415 2484 2553 2416 2416 2416 2484 2415 2415 2415 2415 2483 2414 2414 2414 2550 2412 2412 2...

output:

2594
8074
9162
8784
1723

result:

ok 5 lines

Test #45:

score: 15
Accepted
time: 115ms
memory: 4292kb

input:

5 8
20000 20000 1821
12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 12473 124...

output:

12444
5
16336
26
3404

result:

ok 5 lines

Test #46:

score: 15
Accepted
time: 391ms
memory: 6316kb

input:

2 8
50000 50000 816
49999 50000 50000 49999 50000 49999 49999 49999 50000 49999 50000 49999 49999 49999 50000 50000 50000 50000 49999 50000 49999 49999 49999 50000 49999 49999 49999 50000 50000 49999 49999 49999 50000 50000 49999 49999 49999 49999 49999 49999 49999 50000 50000 50000 50000 49999 4999...

output:

50000
50000

result:

ok 2 lines

Subtask #9:

score: 0
Skipped

Dependency #1:

0%

Subtask #10:

score: 0
Skipped

Dependency #2:

0%