QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581818#2784. AliensNuclearPasta4 6ms6512kbC++142.2kb2024-09-22 14:16:302024-09-22 14:16:30

Judging History

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

  • [2024-09-22 14:16:30]
  • 评测
  • 测评结果:4
  • 用时:6ms
  • 内存:6512kb
  • [2024-09-22 14:16:30]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n,m,ik,pn;
long long dp[100009],ct[100009];
struct line{
	int l,r;
	bool operator<(const line &b)const{
		return l < b.l || (l == b.l && r > b.r);
	}
}ln[100009],ls[100009];
long long b(int x){
	return dp[x] + 1ll * ln[x + 1].l * ln[x + 1].l - 1ll * max(0,ln[x].r - ln[x + 1].l) * max(0,ln[x].r - ln[x + 1].l);
}
long long k(int x){
	return -2ll * ln[x + 1].l;
}
long long w(int x,long long fk){
	return 1ll * ln[x].r * ln[x].r - fk;
}
bool chk1(int x,int y,int z){
	//printf(" %d %d %d\n",x,y,z);
	return (b(x) - b(z)) * (k(z) - k(y)) < (b(y) - b(z)) * (k(z) - k(x)) || ((b(x) - b(z)) * (k(z) - k(y)) == (b(y) - b(z)) * (k(z) - k(x)) && ct[x] <= ct[y]);
}
bool chk2(int x,int y,int t){
	//printf(" %d %d\n",b(x) + k(x) * t,b(y) + k(y) * t);
	return b(x) + k(x) * t > b(y) + k(y) * t || (b(x) + k(x) * t == b(y) + k(y) * t && ct[x] >= ct[y]);
}
int q[100009],head,tail;
void gt(long long fk){
	dp[0] = 0;
	ct[0] = 0;
	head = tail = 1;
	q[1] = 0;
	for(int i = 1; i <= n; i ++){
		//printf("%d %d\n",ln[i].l,ln[i].r);
		while(head <= tail - 1 && chk2(q[head],q[head + 1],ln[i].r))
			head ++;
		dp[i] = b(q[head]) + k(q[head]) * ln[i].r + w(i,fk);
		ct[i] = ct[q[head]] + 1;
		//printf("%lld %d %lld %lld %lld\n",dp[i],q[head],k(q[head]),b(q[head]),w(i,fk));
		if(k(q[tail]) == k(i) && b(q[tail]) == b(i) && ct[q[tail]] <= ct[i])
			continue;
		while(head <= tail - 1 && chk1(q[tail - 1],q[tail],i))
			tail --;
		q[++tail] = i;
	}
	//printf("%lld %lld %lld\n",fk,dp[n],ct[n]);
}
long long take_photos(int pn,int m,int ik,vector<int,std::allocator<int> >r,vector<int,std::allocator<int> >c){
	for(int i = 1; i <= pn; i ++){
		ls[i].l = r[i - 1],ls[i].r = c[i - 1];
		if(ls[i].l > ls[i].r)
			swap(ls[i].l,ls[i].r);
	//	printf(" %d %d\n",ls[i].l,ls[i].r);
	}
	sort(ls + 1,ls + pn + 1);
	for(int i = 1; i <= pn; i ++){
		if(i == 1 || ls[i].r >= ln[n].r)
			ln[++n] = ls[i],ln[n].r ++;
		//printf("%d\n",n);
	}
	long long l = -1ll * m * m - 9,rt = 1;
	while(l + 1 < rt){
		long long mid = (l + rt + 1) >> 1;
		gt(mid);
		if(ct[n] > ik)
			rt = mid;
		else
			l = mid;
	}
	gt(l);
	//printf("%d %d\n",ik,l);
	return dp[n] + 1ll * ik * l;
}

詳細信息

Subtask #1:

score: 4
Accepted

Test #1:

score: 4
Accepted
time: 0ms
memory: 3796kb

input:

2 6 2
1 4
4 1

output:

098d134608c94f7413faac591054ee35
16

result:

ok Correct answer: answer = 16

Test #2:

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

input:

1 2 1
0 1

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #3:

score: 4
Accepted
time: 0ms
memory: 5856kb

input:

2 2 2
0 0
1 0

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #4:

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

input:

2 3 2
0 1
1 1

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #5:

score: 4
Accepted
time: 1ms
memory: 5828kb

input:

4 4 4
1 3
0 1
2 1
2 2

output:

098d134608c94f7413faac591054ee35
12

result:

ok Correct answer: answer = 12

Test #6:

score: 4
Accepted
time: 0ms
memory: 4044kb

input:

5 8 5
0 5
2 6
7 4
4 5
2 6

output:

098d134608c94f7413faac591054ee35
52

result:

ok Correct answer: answer = 52

Test #7:

score: 4
Accepted
time: 1ms
memory: 5828kb

input:

8 20 8
6 14
5 13
1 8
17 15
6 9
1 9
2 0
17 8

output:

098d134608c94f7413faac591054ee35
210

result:

ok Correct answer: answer = 210

Test #8:

score: 4
Accepted
time: 1ms
memory: 6116kb

input:

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

output:

098d134608c94f7413faac591054ee35
88

result:

ok Correct answer: answer = 88

Test #9:

score: 4
Accepted
time: 0ms
memory: 6088kb

input:

10 100 10
98 25
55 31
36 25
38 77
9 82
11 69
88 42
47 49
19 91
61 13

output:

098d134608c94f7413faac591054ee35
7696

result:

ok Correct answer: answer = 7696

Test #10:

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

input:

50 1 50
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:

098d134608c94f7413faac591054ee35
1

result:

ok Correct answer: answer = 1

Test #11:

score: 4
Accepted
time: 1ms
memory: 5840kb

input:

50 50 50
25 25
44 12
46 47
4 26
10 35
10 3
13 27
14 16
6 28
10 0
27 46
2 19
10 36
29 49
13 16
6 38
32 48
33 33
47 45
8 13
5 21
14 25
21 41
47 49
26 7
4 7
5 34
5 24
16 24
18 26
29 10
32 39
14 39
35 32
11 1
49 17
24 18
38 14
32 48
46 1
45 46
17 36
29 31
24 48
12 33
4 44
38 32
11 6
25 47
9 49

output:

098d134608c94f7413faac591054ee35
2374

result:

ok Correct answer: answer = 2374

Test #12:

score: 4
Accepted
time: 1ms
memory: 5928kb

input:

50 100 50
0 20
49 26
21 27
10 67
79 9
38 75
39 27
36 51
75 81
70 37
57 74
57 64
13 76
53 95
25 11
62 37
78 38
39 19
46 7
92 71
40 27
73 11
30 55
60 67
79 48
3 69
1 27
41 54
80 40
50 50
9 49
75 11
90 62
2 71
14 40
30 48
3 53
68 24
99 25
8 49
35 80
31 24
21 11
92 9
4 97
45 61
56 83
68 75
35 84
77 20

output:

098d134608c94f7413faac591054ee35
9502

result:

ok Correct answer: answer = 9502

Test #13:

score: 4
Accepted
time: 1ms
memory: 5824kb

input:

49 7 49
5 3
0 6
6 2
3 3
4 2
3 4
0 3
1 3
2 4
5 1
1 0
2 1
3 0
4 4
1 6
0 5
1 4
6 3
6 6
6 5
4 0
3 5
5 5
2 0
4 5
3 2
0 2
1 5
2 5
6 4
1 1
5 0
0 4
6 0
5 4
2 6
0 1
5 2
4 6
5 6
3 1
3 6
0 0
4 3
1 2
2 2
4 1
2 3
6 1

output:

098d134608c94f7413faac591054ee35
49

result:

ok Correct answer: answer = 49

Test #14:

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

input:

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

output:

098d134608c94f7413faac591054ee35
151

result:

ok Correct answer: answer = 151

Test #15:

score: 4
Accepted
time: 1ms
memory: 6084kb

input:

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

output:

098d134608c94f7413faac591054ee35
7550

result:

ok Correct answer: answer = 7550

Test #16:

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

input:

50 100 50
37 79
7 50
40 90
24 69
27 75
25 70
46 99
9 54
19 62
35 78
8 51
11 60
21 67
30 75
11 57
4 50
10 55
40 92
45 97
41 95
27 73
25 71
38 80
11 57
30 75
24 68
2 49
11 56
20 64
40 92
9 53
35 77
3 49
39 83
37 80
20 67
1 48
36 79
31 76
38 81
21 68
26 71
0 48
27 75
9 53
13 61
27 74
14 62
39 84
3 49

output:

098d134608c94f7413faac591054ee35
7220

result:

ok Correct answer: answer = 7220

Test #17:

score: 4
Accepted
time: 1ms
memory: 6112kb

input:

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

output:

098d134608c94f7413faac591054ee35
7550

result:

ok Correct answer: answer = 7550

Test #18:

score: 4
Accepted
time: 1ms
memory: 6132kb

input:

50 100 50
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99

output:

098d134608c94f7413faac591054ee35
10000

result:

ok Correct answer: answer = 10000

Test #19:

score: 4
Accepted
time: 1ms
memory: 5860kb

input:

50 100 50
0 99
1 98
3 98
3 96
3 96
4 93
4 92
5 92
6 91
8 91
9 91
10 90
11 90
12 85
12 82
17 82
19 82
19 81
20 80
21 76
21 76
22 75
22 75
23 73
23 72
24 72
24 71
25 71
25 70
28 68
28 66
29 66
30 64
31 63
31 63
33 62
34 61
36 60
37 60
39 60
40 59
43 59
44 59
45 58
45 57
46 56
47 55
50 53
50 52
51 52

output:

098d134608c94f7413faac591054ee35
10000

result:

ok Correct answer: answer = 10000

Test #20:

score: 4
Accepted
time: 0ms
memory: 4084kb

input:

50 100 50
61 62
12 15
81 81
49 50
78 85
62 69
55 61
57 57
22 25
77 78
2 5
8 12
62 67
49 50
19 25
60 62
71 77
74 74
90 95
33 34
24 26
47 54
45 51
72 75
89 89
18 19
36 38
6 8
1 3
25 26
73 77
35 38
1 4
55 57
85 91
82 86
66 66
18 18
3 5
61 64
32 32
21 22
61 63
79 83
74 80
68 74
72 75
75 81
66 69
51 55

output:

098d134608c94f7413faac591054ee35
624

result:

ok Correct answer: answer = 624

Test #21:

score: 4
Accepted
time: 1ms
memory: 5912kb

input:

50 100 50
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99
0 99

output:

098d134608c94f7413faac591054ee35
10000

result:

ok Correct answer: answer = 10000

Test #22:

score: 4
Accepted
time: 0ms
memory: 3876kb

input:

1 1 1
0 0

output:

098d134608c94f7413faac591054ee35
1

result:

ok Correct answer: answer = 1

Subtask #2:

score: 0
Wrong Answer

Test #23:

score: 12
Accepted
time: 0ms
memory: 3748kb

input:

2 2 1
0 0
1 1

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #24:

score: 12
Accepted
time: 0ms
memory: 6112kb

input:

4 3 2
0 0
0 0
0 0
0 0

output:

098d134608c94f7413faac591054ee35
1

result:

ok Correct answer: answer = 1

Test #25:

score: 12
Accepted
time: 0ms
memory: 5916kb

input:

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

output:

098d134608c94f7413faac591054ee35
5

result:

ok Correct answer: answer = 5

Test #26:

score: 0
Wrong Answer
time: 1ms
memory: 5856kb

input:

10 20 3
3 3
15 15
10 10
18 18
4 4
7 7
15 15
2 2
10 10
7 7

output:

098d134608c94f7413faac591054ee35
53

result:

wrong answer Wrong answer: output = 53, expected = 41

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #5:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #112:

score: 0
Wrong Answer
time: 6ms
memory: 6512kb

input:

50000 1000000 3
360946 187012
56354 290116
389944 194589
327798 454716
248464 891509
615396 878303
736802 689759
446833 816714
552228 948958
34870 257015
911026 191884
761150 821028
341778 82756
125288 719663
86132 290045
145161 627383
25381 217026
756213 671192
686079 478553
648300 785174
706912 93...

output:

098d134608c94f7413faac591054ee35
999897879749

result:

wrong answer Wrong answer: output = 999897879749, expected = 999889968863

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%