QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#858487#9675. 电池检测KaXdd_#20 3ms11512kbC++142.8kb2025-01-16 17:48:152025-01-16 17:48:15

Judging History

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

  • [2025-01-16 17:48:15]
  • 评测
  • 测评结果:20
  • 用时:3ms
  • 内存:11512kb
  • [2025-01-16 17:48:15]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define rg register
#define il inline
#define TT(T, Args) template<typename T, typename... Args>
#define L(i, a, b) for (rg int i = (a); i <= (b); i++)
#define R(i, a, b) for (rg int i = (a); i >= (b); i--)
#define rep(i, a) for (rg auto i : a)
using namespace std;
namespace xmpl_{
	il int rd(){
		int f = 1, x = 0;
		char ch = getchar();
		while(ch < '0' || ch > '9'){
			if (ch == '-') f = -1;
			ch = getchar();
		}
		while(ch >= '0' && ch <= '9'){
			x = x * 10 + ch - '0';
			ch = getchar();
		}
		return x * f;
	}
	TT(T, Args) il void rd(T &x){
		int f = 1;
		x = 0;
		char ch = getchar();
		while(ch < '0' || ch > '9'){
			if (ch == '-') f = -1;
			ch = getchar();
		}
		while(ch >= '0' && ch <= '9'){
			x = x * 10 + ch - '0';
			ch = getchar();
		}
		x *= f;
	}
	TT(T, Args) il void rd(T &x, Args &...args){rd(x), rd(args...);}
	TT(T, Args) il void rdArr(T *arr, int cnt){while(cnt--) rd(*arr), arr++;}
	il void wt(int x){
		if (x < 0){
			putchar('-');
			x = -x;
		}
		if (x > 9) wt(x / 10);
		putchar(x % 10 + 48);
	}
	il void wtln(int x){wt(x), putchar('\n');}
	il void wtsp(int x){wt(x), putchar(' ');}
	il void swap(int &x, int &y){x ^= y ^= x ^= y;}
	il int max(int x, int y){return (x > y ? x : y);}
	il int min(int x, int y){return (x < y ? x : y);}
	il void ckmax(int &x, int y){x = max(x, y);}
	il void ckmin(int &x, int y){x = min(x, y);}
	il void cksum(int &x, int y){x += y;}
	TT(T, Args) il void ckmax(T &x, T y, Args &...args){ckmax(x, y), ckmax(x, args...);}
	TT(T, Args) il void ckmin(T &x, T y, Args &...args){ckmin(x, y), ckmin(x, args...);}
	TT(T, Args) il void cksum(T &x, T y, Args &...args){cksum(x, y), cksum(x, args...);}
}
using namespace xmpl_;
using namespace std;

const int N = 1e3 + 5, M = 21, p = 1e9 + 7, inf = 0x3f3f3f3f3f3f3f3f;
int a, b, F[N][N];

il void init(){
	memset(F, 0x3f, sizeof(F));
	// L(i, 2, 1000) F[i][0] = 1;
	F[2][1] = 3;
	L(i, 3, 1000) F[i][1] = 2;
	// L(i, 2, 1000){
	// 	L(j, 2, 1000){
	// 		L(k, 1, j - 1){
	// 			ckmin(F[i][j], min(F[i - 1][j - k] + k * (k - 1) / 2, i * j + j * (j - 1) / 2 + 1));
	// 		}
	// 	}
	// }
	L(i, 2, 1000){
		L(j, 2, 1000){
			ckmin(F[i][j], min(F[i - 1][j - 1] + 1, min(F[i - 1][j - 2] + 3, i * j + j * (j - 1) / 2 + 1)));
		}
	}
	// L(j, 2, 1000){
	// 	wtsp(F[2][j]), wtln((2 + j) * (1 + j) / 2);
	// }
}

il void clear(){
	
}

il void work(){
	rd(a, b);
	// if (a == 2 && b == 1) return wt(3), void();
	// if (a == 2) return wt((a + b) * (a + b - 1) / 2), void();
	// if (a <= b + 1) wt(F[a][b]);
	// else wt(b + 1);
	wt(F[a][b]);
}

signed main(){
	// #define file 114514
#ifdef file	
	freopen("code.in", "r", stdin);
	freopen("code.out", "w", stdout);
#endif
	init();
	int t = 1;
	t = rd();
	while(t--){
		clear();
		work();
		puts("");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

3
2 1
3 1
2 2

output:

3
2
6

result:

ok 3 number(s): "3 2 6"

Test #2:

score: 10
Accepted
time: 3ms
memory: 11512kb

input:

12
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4
4 1
4 2
4 3
4 4

output:

3
6
10
15
2
4
6
9
2
3
5
7

result:

ok 12 numbers

Subtask #2:

score: 5
Accepted

Test #3:

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

input:

1000
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
2 21
2 22
2 23
2 24
2 25
2 26
2 27
2 28
2 29
2 30
2 31
2 32
2 33
2 34
2 35
2 36
2 37
2 38
2 39
2 40
2 41
2 42
2 43
2 44
2 45
2 46
2 47
2 48
2 49
2 50
2 51
2 52
2 53
2 54
2 55
2 56
2 57
2 58
2 59
2 60
2 61...

output:

3
6
10
15
21
28
36
45
55
66
78
91
105
120
136
153
171
190
210
231
253
276
300
325
351
378
406
435
465
496
528
561
595
630
666
703
741
780
820
861
903
946
990
1035
1081
1128
1176
1225
1275
1326
1378
1431
1485
1540
1596
1653
1711
1770
1830
1891
1953
2016
2080
2145
2211
2278
2346
2415
2485
2556
2628
27...

result:

ok 1000 numbers

Subtask #3:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 2ms
memory: 11480kb

input:

1000
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
3 16
3 17
3 18
3 19
3 20
3 21
3 22
3 23
3 24
3 25
3 26
3 27
3 28
3 29
3 30
3 31
3 32
3 33
3 34
3 35
3 36
3 37
3 38
3 39
3 40
3 41
3 42
3 43
3 44
3 45
3 46
3 47
3 48
3 49
3 50
3 51
3 52
3 53
3 54
3 55
3 56
3 57
3 58
3 59
3 60
3 61...

output:

2
4
6
9
13
18
24
31
39
48
58
69
81
94
108
123
139
156
174
193
213
234
256
279
303
328
354
381
409
438
468
499
531
564
598
633
669
706
744
783
823
864
906
949
993
1038
1084
1131
1179
1228
1278
1329
1381
1434
1488
1543
1599
1656
1714
1773
1833
1894
1956
2019
2083
2148
2214
2281
2349
2418
2488
2559
263...

result:

wrong answer 5th numbers differ - expected: '12', found: '13'

Subtask #4:

score: 5
Accepted

Test #5:

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

input:

1000
907 241
495 435
227 139
616 1
433 35
588 407
533 322
995 961
748 310
212 36
968 500
294 187
375 371
307 14
648 180
122 28
304 253
818 812
41 5
286 62
573 340
547 224
347 35
279 56
151 85
626 410
456 248
578 470
11 6
952 771
404 302
77 27
168 40
524 517
171 147
407 294
268 106
100 27
549 196
973...

output:

242
436
140
2
36
408
323
962
311
37
501
188
372
15
181
29
254
813
6
63
341
225
36
57
86
411
249
471
7
772
303
28
41
518
148
295
107
28
197
374
35
337
236
92
714
832
465
377
70
496
141
52
38
47
632
355
96
329
130
395
233
124
815
408
201
20
56
630
544
62
379
618
415
17
131
265
179
232
316
109
60
266
7...

result:

ok 1000 numbers

Subtask #5:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #6:

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

input:

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

output:

3
6
10
15
21
28
36
45
55
66
2
4
6
9
13
18
24
31
39
48
2
3
5
7
9
12
16
21
27
34
2
3
4
6
8
10
12
15
19
24
2
3
4
5
7
9
11
13
15
18
2
3
4
5
6
8
10
12
14
16
2
3
4
5
6
7
9
11
13
15
2
3
4
5
6
7
8
10
12
14
2
3
4
5
6
7
8
9
11
13

result:

wrong answer 15th numbers differ - expected: '12', found: '13'

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%