QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#798993#7253. JumpInvincibleAC ✓1730ms58788kbC++232.2kb2024-12-04 20:09:292024-12-04 20:09:29

Judging History

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

  • [2024-12-04 20:09:29]
  • 评测
  • 测评结果:AC
  • 用时:1730ms
  • 内存:58788kb
  • [2024-12-04 20:09:29]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <ctime>
#include <random>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#define pii pair<int, int>
#define fi first
#define se second
#define MP make_pair
#define ep emplace
#define eb emplace_back
//#define int long long
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
typedef double db;
typedef long double ldb;
typedef long long ll;
//typedef __int128 lll;
typedef unsigned long long ull;
typedef unsigned int ui;
using namespace std;
using namespace __gnu_pbds;
bool Mbe;

//char buf[1<<20],*p1,*p2;
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin), p1 == p2) ? 0 : *p1++)
int read() {
	int s = 0, f = 1;
	char c = getchar();
	while (c < '0' || c > '9') f ^= (c == '-'), c = getchar();
	while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
	return f ? s : -s;
}
template<typename T>void chkmax(T&x,const T&y){x=max(x,y);}
template<typename T>void chkmin(T&x,const T&y){x=min(x,y);}

const int N=205;
int n,a[N],ansg[20005],ansf[20005];
bitset<40000>f[10005],g[10005];

bool Med;
signed main() {
	fprintf(stderr,"%.3lfMb\n",(&Mbe-&Med)/1024./1024.);
	n=read();
	rep(i,1,n)a[i]=read();
	f[0].set(20000);
	rep(i,1,5000){
		rep(j,1,n)g[i]|=f[i-1]<<a[j];
		rep(j,1,n)f[i]|=g[i]>>a[j];
	}
	memset(ansf,-1,sizeof ansf);
	memset(ansg,-1,sizeof ansg);
	rep(j,0,20000){
		ansg[j]=ansf[j]=-1;
		rep(i,0,5000){
			if(g[i][j+20000]){
				ansg[j]=i;
				break;
			}
		} 
		rep(i,0,5000){
			if(f[i][j+20000]){
				ansf[j]=i;
				break;
			}
		}
	}
	for(int Q=read();Q--;){
		int s=read(),t=read();
		if((s^t)&1){
			printf("-1\n");
			continue;
		}
		if(s>t)swap(s,t);
		if(!~ansf[(t-s)/2]&&!~ansg[(s+t)/2]){
			printf("-1\n");
			continue;
		}
		int ans=1e9;
		if(~ansf[(t-s)/2])ans=min(ans,ansf[(t-s)/2]*2);
		if(~ansg[(s+t)/2])ans=min(ans,ansg[(s+t)/2]*2-1);
		printf("%d\n",ans);
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 65ms
memory: 56040kb

input:

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

output:

-1
-1
2
2
-1
-1
0
3
1
0

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 58ms
memory: 55296kb

input:

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

output:

-1
1
2
-1
1
3
2
2
3
3

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 1632ms
memory: 54952kb

input:

200
12
14
30
101
217
243
267
357
402
442
457
477
579
617
687
691
808
1033
1170
1221
1224
1250
1467
1634
1642
1651
1665
1755
1758
1764
1811
1813
1814
1837
1890
1936
2001
2224
2236
2262
2292
2364
2368
2423
2565
2576
2586
2617
2731
2742
2798
2848
2886
2887
2904
2928
2950
3086
3091
3206
3250
3275
3433
3...

output:

2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 100000 numbers

Test #4:

score: 0
Accepted
time: 1634ms
memory: 55580kb

input:

200
13
22
196
211
212
233
271
284
440
460
547
641
780
804
814
822
887
892
934
971
1066
1106
1145
1148
1161
1390
1579
1582
1697
1786
1891
1893
1900
1934
1954
1955
1980
2096
2126
2321
2422
2454
2524
2773
2864
2888
2902
2924
2964
2967
2981
3041
3276
3282
3355
3607
3620
3684
3714
3764
3779
3780
3788
380...

output:

2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 100000 numbers

Test #5:

score: 0
Accepted
time: 1620ms
memory: 54904kb

input:

200
10
41
107
167
256
306
486
512
532
555
591
601
715
743
916
1017
1024
1091
1099
1209
1415
1531
1582
1607
1633
1669
1771
1791
1876
1951
2193
2200
2334
2338
2388
2446
2451
2460
2540
2651
2697
2704
2733
2737
2881
2941
2967
2982
3004
3062
3306
3317
3335
3349
3351
3366
3379
3579
3592
3679
3737
3764
379...

output:

2
1
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
...

result:

ok 100000 numbers

Test #6:

score: 0
Accepted
time: 1646ms
memory: 55712kb

input:

200
91
166
275
278
325
344
355
481
501
604
613
619
634
635
690
698
739
753
856
929
1001
1031
1037
1064
1145
1283
1315
1317
1318
1353
1382
1387
1406
1424
1430
1465
1474
1489
1570
1599
1626
1654
1681
1696
1697
1721
1743
1905
1967
2033
2065
2101
2107
2124
2159
2166
2171
2195
2286
2395
2423
2450
2467
25...

output:

2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
3
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
...

result:

ok 100000 numbers

Test #7:

score: 0
Accepted
time: 1636ms
memory: 55360kb

input:

200
18
104
138
182
209
290
294
369
376
393
414
437
468
487
519
531
591
715
738
740
1146
1153
1187
1284
1396
1465
1535
1588
1589
1735
1819
1827
1886
1903
1916
2003
2012
2038
2094
2137
2143
2157
2160
2167
2224
2229
2325
2337
2398
2489
2528
2765
2800
2887
2930
2955
3088
3093
3106
3169
3179
3222
3225
33...

output:

2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
3
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
1
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 1624ms
memory: 55224kb

input:

200
115
144
272
274
310
333
429
451
493
640
642
683
704
724
857
894
935
990
1042
1046
1053
1092
1098
1226
1284
1340
1402
1425
1624
1658
1675
1751
1759
1762
1858
1861
1891
1899
2036
2059
2103
2163
2335
2478
2530
2535
2543
2575
2651
2758
2789
2835
2922
2937
2970
2979
3057
3242
3250
3390
3398
3469
3578...

output:

2
2
2
2
2
3
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
3
3
2
2
2
1
1
2
1
2
2
...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 1641ms
memory: 55984kb

input:

200
84
177
208
219
234
280
285
372
374
422
462
480
531
600
619
659
839
842
858
965
1070
1097
1105
1112
1134
1162
1190
1195
1414
1433
1455
1513
1667
1731
1782
1867
1957
1960
1962
1974
1979
2236
2276
2343
2358
2414
2654
2658
2735
2736
2841
2871
2916
3046
3112
3139
3175
3220
3288
3292
3420
3440
3452
34...

output:

2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
1
2
3
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
1
2
2
3
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 1622ms
memory: 55968kb

input:

200
96
131
228
258
267
380
462
566
722
769
781
808
877
908
909
991
1032
1057
1065
1131
1274
1377
1858
1915
1945
1996
2100
2113
2144
2149
2201
2232
2276
2279
2318
2341
2350
2487
2561
2705
2717
2762
2852
2896
2898
2910
2934
3010
3039
3081
3093
3162
3163
3171
3217
3218
3300
3303
3469
3551
3637
3689
369...

output:

2
2
2
2
2
3
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
3
3
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 1635ms
memory: 57072kb

input:

200
0
77
132
189
287
326
327
328
379
511
516
540
566
640
682
729
822
855
958
1044
1069
1202
1213
1273
1314
1344
1387
1447
1450
1518
1530
1569
1580
1635
1740
1760
1803
1822
1855
1869
1979
2040
2050
2072
2327
2411
2417
2443
2611
2619
2680
2694
2702
2728
2748
2798
2806
2866
2997
3009
3140
3190
3196
322...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 1625ms
memory: 55064kb

input:

200
3
33
74
118
182
252
387
429
507
539
565
589
602
626
686
728
860
867
868
887
900
945
969
1143
1284
1337
1394
1420
1674
1771
1817
1921
1924
1927
1948
1955
1962
2016
2039
2096
2237
2319
2434
2464
2530
2602
2667
2700
2710
2841
2874
2897
2956
2957
3250
3271
3356
3373
3391
3509
3565
3614
3706
3793
386...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
3
2
1
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
1
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 1631ms
memory: 56332kb

input:

200
95
162
171
448
451
528
683
735
764
770
865
894
948
979
1030
1142
1152
1308
1365
1407
1409
1411
1432
1436
1447
1468
1531
1536
1574
1722
1761
1929
1931
1939
1955
1979
1990
2011
2020
2127
2174
2179
2202
2255
2268
2296
2340
2454
2492
2498
2562
2571
2652
2662
2803
2856
2943
2967
2975
3098
3104
3135
3...

output:

-1
-1
2
2
2
-1
-1
-1
-1
2
2
2
-1
-1
-1
-1
-1
-1
-1
2
-1
-1
-1
2
-1
-1
-1
2
-1
2
-1
-1
-1
2
-1
2
-1
-1
-1
2
2
2
2
-1
2
-1
-1
-1
-1
2
-1
2
-1
2
2
-1
2
2
-1
-1
-1
2
-1
2
-1
-1
-1
2
2
2
2
-1
2
2
-1
-1
2
2
2
2
-1
-1
2
2
2
2
2
-1
2
-1
2
2
2
-1
2
2
-1
-1
-1
-1
2
-1
-1
1
-1
2
2
2
2
2
-1
-1
-1
2
-1
-1
1
2
-1...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 1631ms
memory: 55160kb

input:

200
32
72
229
239
240
399
438
686
695
794
881
1013
1028
1115
1125
1138
1151
1197
1229
1275
1330
1451
1484
1491
1508
1543
1555
1559
1573
1598
1654
1932
1987
2031
2076
2103
2135
2200
2264
2345
2358
2368
2369
2394
2409
2460
2631
2807
2813
2872
2919
2955
2958
3022
3062
3171
3211
3228
3286
3328
3448
3559...

output:

2
-1
2
2
-1
2
-1
2
-1
2
-1
2
-1
-1
2
-1
2
-1
-1
-1
2
-1
-1
-1
2
2
2
-1
-1
-1
-1
2
-1
2
2
-1
-1
2
2
-1
2
-1
2
-1
2
-1
2
2
2
-1
-1
2
2
3
2
2
-1
2
2
2
-1
2
-1
2
2
2
2
2
-1
2
-1
2
2
-1
-1
-1
-1
-1
-1
2
2
2
2
-1
2
-1
2
-1
2
-1
-1
-1
2
-1
-1
-1
-1
-1
2
-1
2
2
2
-1
-1
-1
-1
2
-1
-1
-1
2
2
-1
2
-1
2
2
-1
-1...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 1675ms
memory: 56140kb

input:

200
30
124
136
176
184
224
252
335
377
413
414
419
436
498
583
612
652
653
676
726
728
822
826
895
932
1002
1010
1036
1043
1217
1286
1300
1305
1315
1322
1404
1544
1687
1689
1694
1709
1735
1753
1838
1849
1944
1966
1986
2060
2067
2068
2078
2104
2116
2117
2148
2197
2225
2237
2246
2279
2306
2314
2323
23...

output:

2
-1
2
-1
2
-1
2
-1
2
-1
2
2
-1
-1
-1
-1
-1
-1
2
3
-1
-1
2
-1
2
2
-1
-1
-1
2
2
2
2
2
-1
-1
2
2
2
3
2
-1
-1
2
2
2
-1
-1
-1
-1
-1
-1
2
-1
2
2
-1
2
-1
2
2
2
-1
2
2
2
2
-1
-1
-1
1
2
2
2
-1
2
-1
-1
-1
2
2
3
-1
-1
2
-1
-1
2
-1
2
2
2
2
-1
-1
-1
-1
2
3
2
2
2
2
2
2
2
-1
-1
-1
2
-1
2
2
-1
-1
1
2
-1
-1
2
2
2
2...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 199ms
memory: 55980kb

input:

22
68
165
622
768
1358
1395
1500
1723
1959
2180
2583
2826
3202
3261
3267
3397
3451
3528
3711
3779
3829
3838
100000
1268 1918
580 1392
2039 3639
3286 1204
1620 614
1096 692
498 3120
3606 234
3592 2092
2180 3346
2024 2232
653 417
1122 2690
1901 1133
3560 3280
2272 1122
2341 1447
970 1056
3246 1842
199...

output:

3
4
4
3
4
4
4
3
4
4
4
2
3
4
4
4
3
3
2
3
4
3
3
3
3
3
3
4
4
4
2
4
3
3
4
3
4
4
4
4
4
3
3
3
3
4
4
3
3
4
3
3
3
3
4
4
3
4
3
3
4
4
3
4
3
3
4
3
4
3
3
4
4
4
4
3
3
4
4
3
4
4
4
4
3
2
2
2
2
3
4
4
3
3
3
3
4
4
3
3
4
4
3
3
3
3
4
3
3
3
2
4
4
3
4
2
4
4
3
3
3
4
4
3
3
3
4
4
3
3
3
3
4
3
4
3
3
3
2
3
4
3
3
3
4
3
3
4
3
4
...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 932ms
memory: 55844kb

input:

113
47
92
144
213
218
280
328
424
425
629
736
851
884
1037
1098
1198
1215
1224
1240
1360
1370
1413
1434
1643
1669
1904
1991
2046
2092
2127
2149
2175
2216
2283
2306
2308
2357
2498
2685
2722
2922
2976
3025
3047
3089
3413
3548
3568
3571
3615
3635
3873
4213
4362
4460
4506
4540
4657
4663
4740
4769
4832
4...

output:

2
2
2
3
2
3
2
2
3
2
2
3
2
2
2
3
2
2
2
3
3
3
2
2
2
2
3
2
2
2
2
3
2
2
2
2
2
3
2
2
2
2
2
2
2
2
3
2
2
2
3
2
2
2
2
3
2
2
2
2
2
3
2
2
2
2
2
3
2
3
2
2
2
2
2
3
3
3
2
2
2
2
3
2
2
2
2
2
3
2
2
2
2
3
2
3
2
2
2
3
2
2
2
3
3
2
2
2
3
2
2
2
2
3
3
2
2
2
2
3
2
2
2
3
3
2
3
1
3
2
2
2
2
3
3
2
2
2
2
2
2
2
2
3
2
2
2
3
2
3
...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 1103ms
memory: 55688kb

input:

132
23
58
111
122
146
159
160
181
195
346
371
401
416
513
562
575
623
664
706
801
809
825
899
1014
1111
1247
1250
1282
1345
1347
1349
1358
1468
1481
1501
1525
1536
1585
1620
1657
1757
1845
1850
1883
2128
2140
2319
2336
2384
2397
2422
2539
2597
2607
2625
2837
2843
2891
2928
2982
2991
3013
3102
3113
3...

output:

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

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 1730ms
memory: 56456kb

input:

200
0
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
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:

30
24
36
14
16
2
14
10
4
14
22
16
4
26
2
12
20
16
4
8
38
20
16
2
20
41
6
14
42
24
44
4
28
22
20
6
16
44
20
2
24
12
18
8
9
16
12
20
20
18
4
2
5
6
8
6
2
6
12
4
12
2
16
14
2
32
18
16
10
10
32
20
4
26
12
9
22
6
24
20
10
14
12
18
6
28
16
12
38
16
16
24
4
12
8
20
30
22
12
2
24
12
6
4
42
6
30
22
28
38
26
2...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 129ms
memory: 58676kb

input:

1
2894
100000
1754 10
4480 5082
4672 2376
2601 2653
1480 4574
3486 1160
299 1157
3257 1455
4806 1934
3994 4586
4719 1853
2748 4692
3880 3790
1786 3710
1855 4071
637 865
420 524
1259 509
3643 1343
1516 3624
153 645
5538 5280
3294 3428
4165 2415
3428 3848
4058 2410
4328 5756
707 3955
5257 391
5387 190...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 130ms
memory: 56536kb

input:

2
1205
2450
100000
3284 4970
786 4554
1510 7456
4498 3676
275 5473
6121 1255
7263 1223
5996 2540
287 83
5168 852
4769 2831
942 2246
360 5652
6516 3924
6918 6896
1469 2053
6832 1546
4661 5869
3082 5840
1728 4052
4151 599
6072 2938
2740 1328
2758 2172
2142 1766
4098 7058
5597 6277
1839 2355
6290 1206
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 35ms
memory: 56660kb

input:

3
43
160
246
100000
3001 3035
1286 2692
1398 464
585 773
3930 1662
1444 832
3829 3143
2064 1200
3195 713
3393 2413
4596 14
1454 1746
1084 2848
3891 143
1582 3568
4136 4244
2818 1676
2053 3129
1395 2345
3311 687
2653 1385
2195 1749
3357 3375
3908 776
52 2762
4505 2179
4331 75
2813 723
3715 3669
1817 ...

output:

24
130
35
63
53
26
126
71
128
93
58
176
41
113
47
115
18
148
17
130
108
76
83
58
74
14
89
114
128
48
86
26
163
39
154
18
140
98
22
99
28
15
26
70
102
81
75
88
41
37
133
29
12
100
120
107
28
15
80
108
109
88
44
45
47
33
66
41
56
30
20
91
157
79
162
38
136
51
17
75
40
93
75
132
123
76
66
92
105
131
11...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 46ms
memory: 55988kb

input:

4
464
1290
1542
1799
100000
7841 1733
3954 696
903 2767
4690 1536
2011 4253
7592 5088
239 7187
7705 3295
755 5617
7371 413
5146 4908
1528 5962
3084 276
763 2527
1496 6664
1962 108
5464 642
6770 7744
6698 4686
3656 5696
4462 1640
3181 7787
503 6075
5148 4990
469 2655
2800 6364
2715 3901
3273 5209
630...

output:

12
28
53
10
21
33
11
27
23
28
38
25
37
39
13
21
22
26
20
15
37
14
27
40
12
16
37
14
58
30
8
59
18
19
35
19
17
26
28
8
24
39
35
12
15
15
18
20
17
20
11
17
23
44
37
16
30
3
13
17
29
11
8
17
28
31
19
18
18
25
21
3
31
21
11
28
15
41
18
49
36
17
35
13
50
31
41
12
19
47
49
16
45
33
10
14
24
11
10
38
12
33...

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 60ms
memory: 58788kb

input:

5
808
1174
1485
2971
3160
100000
18 682
991 1109
3258 960
2019 2609
589 3165
1459 1465
1815 1085
2523 2965
892 2356
3287 2007
3144 404
433 2659
1344 3024
1713 63
1308 1270
534 1926
1982 1616
289 2421
2976 2890
1758 806
654 1712
2946 40
6 3200
2083 2375
3170 96
1262 1886
748 1216
65 65
2184 3270
1638...

output:

16
11
15
19
19
17
13
16
4
20
11
27
9
20
22
21
28
17
10
10
18
14
19
7
19
11
8
0
6
19
15
7
17
10
15
5
16
11
21
15
16
9
13
4
11
7
12
18
17
25
19
13
14
17
9
19
25
22
19
12
24
25
20
22
20
21
12
17
23
21
16
18
14
17
2
6
24
12
26
25
14
26
13
21
8
14
18
22
20
21
9
16
21
13
23
22
14
19
14
20
8
8
17
19
9
19
1...

result:

ok 100000 numbers

Test #25:

score: 0
Accepted
time: 57ms
memory: 55404kb

input:

6
747
2593
3435
7386
8250
9368
100000
489 455
458 214
2131 813
1305 1939
1971 1661
294 512
2176 2566
439 1665
788 520
989 359
230 476
414 1274
1308 450
1832 218
1469 1041
1131 213
765 1197
635 1861
459 337
1924 1714
677 357
845 2569
2582 1650
2299 1099
592 736
753 1395
1042 2284
586 6
1443 1671
1912...

output:

8
14
18
16
13
8
19
16
17
14
6
8
12
10
9
13
16
15
14
12
23
5
16
13
13
10
13
10
6
7
24
18
9
11
16
9
17
5
13
7
17
8
15
17
11
11
21
13
19
14
13
11
16
11
14
11
5
19
24
14
11
10
13
19
21
8
10
20
11
8
15
17
11
14
8
9
12
25
12
12
13
23
19
21
19
12
19
18
14
18
11
10
15
17
21
18
13
9
10
12
15
21
11
21
12
19
1...

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 71ms
memory: 56256kb

input:

7
73
202
360
488
906
1202
1293
100000
4174 4076
1401 4037
1652 3874
287 4319
5772 1690
1564 1592
2878 6080
4604 4348
5726 718
2601 455
2308 1694
1740 5866
2635 5379
2002 4792
3025 373
2731 2909
142 4744
4124 1754
1963 2521
441 2635
2098 420
4279 5115
5487 1339
2021 3063
1897 5411
1635 6063
5565 2271...

output:

8
7
7
5
8
7
8
2
9
7
7
6
7
8
7
8
5
7
6
7
6
2
7
5
6
7
4
5
5
5
4
7
6
5
9
4
8
5
6
7
7
5
6
6
7
7
2
4
5
7
6
8
8
8
7
6
6
7
6
6
6
8
7
6
8
6
5
8
8
6
7
8
6
8
5
8
4
6
6
4
8
8
8
7
6
8
6
8
2
6
5
4
3
7
7
6
4
6
6
8
6
8
7
8
6
6
8
6
6
7
6
8
5
6
5
6
3
7
8
8
5
6
6
8
6
7
5
5
7
6
8
4
6
4
6
5
4
7
6
6
6
8
6
8
6
5
5
6
4
4
...

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 80ms
memory: 55616kb

input:

8
1690
1707
2399
3939
4113
6430
7433
8625
100000
9248 7680
6824 3628
9106 6778
4589 2863
3189 5201
7658 2942
2518 3324
5156 706
1707 6429
5301 8125
6520 1244
3247 6081
2046 2056
3742 8822
8542 1518
8641 2001
8750 3152
6332 7080
2426 9012
5094 7968
6487 1923
6622 5514
6813 4591
5812 5116
9544 7898
86...

output:

9
10
8
8
8
8
3
9
11
9
9
7
5
10
8
2
10
7
3
6
8
6
5
4
11
7
7
5
7
9
8
7
7
7
7
7
8
4
8
7
8
8
8
8
4
7
8
8
4
7
9
9
8
8
7
8
10
8
7
8
6
7
7
10
6
8
5
9
8
6
10
7
9
10
8
7
6
7
9
9
8
6
4
6
10
5
4
8
6
7
9
7
10
6
5
5
4
7
8
9
6
10
5
9
4
7
6
7
7
8
2
9
8
6
9
9
6
7
9
2
7
7
6
6
10
9
8
7
8
5
10
7
4
5
6
6
11
9
9
9
11
12...

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 82ms
memory: 56484kb

input:

9
541
770
2467
2733
3245
4457
4890
5158
5277
100000
3242 2366
2277 3117
438 1144
1885 469
2634 1094
1443 2623
2459 1183
1902 3170
1767 529
2845 2625
2918 892
1587 203
2228 2710
1773 943
2757 659
919 1713
1117 2119
854 2276
1635 1179
2339 2445
1800 1220
1374 1240
2446 1938
2640 1156
3063 873
276 206
...

output:

6
6
6
5
6
3
6
5
7
3
5
5
5
6
4
6
6
5
5
7
5
6
7
6
5
4
7
7
5
6
6
3
6
7
5
5
6
5
6
6
6
3
5
6
7
6
5
5
3
4
8
6
7
6
5
7
7
5
6
5
7
5
6
7
6
6
7
6
6
5
6
7
4
6
5
6
7
5
5
5
7
6
5
6
5
6
7
6
6
6
7
7
7
4
6
5
6
7
6
7
6
6
5
6
3
5
6
4
7
6
5
7
6
5
5
4
6
5
6
6
6
7
6
6
6
6
6
4
6
6
8
5
6
4
6
6
7
6
4
3
5
6
5
6
3
7
4
4
6
6
...

result:

ok 100000 numbers

Test #29:

score: 0
Accepted
time: 96ms
memory: 56400kb

input:

10
892
1134
1213
1590
3004
3152
5989
7421
7471
7529
100000
2482 4968
4942 4522
3144 2392
1494 4948
4233 4471
2227 3635
4534 3928
4657 2669
965 4013
1772 2264
1356 1222
5069 4745
3193 1497
1889 4629
3403 4537
500 2282
3531 3659
428 3132
4355 1659
4265 4577
2786 4226
1578 3780
3864 524
3029 341
2828 2...

output:

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

result:

ok 100000 numbers

Test #30:

score: 0
Accepted
time: 125ms
memory: 56060kb

input:

2
1517
2330
100000
8617 4901
5281 9927
8967 697
6975 7449
453 395
7637 6263
6089 2353
4338 3396
1382 7850
1965 8829
4276 5000
766 6562
2581 1869
3244 9360
4941 9847
8824 7238
9774 9652
4501 2183
1033 3539
2148 9706
4673 1011
7967 1713
315 8545
425 1491
6311 6963
6477 4479
6689 3457
345 3593
7510 597...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 128ms
memory: 55916kb

input:

2
1476
9919
100000
5659 5295
5883 3375
9679 213
7021 4439
3986 8860
2845 2141
2388 7880
8389 8401
8653 5129
6319 5119
6163 7263
8243 9411
3941 5207
14 6278
1282 9010
7721 9283
6599 943
2252 6502
3110 1506
2570 450
8708 8040
549 4275
1516 7672
2985 1013
9876 3318
9545 2247
6968 4050
8146 5158
7399 70...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #32:

score: 0
Accepted
time: 129ms
memory: 56012kb

input:

2
2401
4549
100000
7074 3288
6669 2939
3230 2782
5871 7305
5108 6798
1017 347
8448 1866
5817 8355
7595 1209
8155 1963
5497 3153
6878 8678
4960 1972
6819 8179
2505 6567
8393 6595
8596 1536
5926 7274
9347 3121
6300 2308
2631 705
2708 2274
3776 9260
3045 1751
2774 1792
957 6893
8604 5218
5126 2094
3940...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #33:

score: 0
Accepted
time: 122ms
memory: 56212kb

input:

2
1905
6720
100000
5628 2990
5516 6640
5735 613
8045 9143
9809 2683
1172 5274
2521 8699
5547 711
4315 1803
6952 3704
3164 3924
865 7963
9464 602
4876 8888
6924 6158
3590 7446
4501 3913
3488 250
7560 2120
2250 1338
9390 1104
9045 6959
7241 5533
997 6369
1023 6697
7297 7285
3879 3085
5510 6580
3307 14...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #34:

score: 0
Accepted
time: 120ms
memory: 55284kb

input:

2
4115
8634
100000
5662 1954
4520 476
3649 8939
9387 5379
8625 3389
454 9482
8062 5270
2298 3902
7523 6829
9968 3860
2524 4442
9245 3117
4727 3393
2328 5784
9404 154
7098 840
9902 7910
9610 7176
7869 7865
9438 4490
0 7334
2039 4533
2167 9915
4488 5024
8199 8183
9195 3223
4586 4104
7982 8820
7994 894...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #35:

score: 0
Accepted
time: 106ms
memory: 58712kb

input:

2
0
1
100000
3826 8633
5076 9192
8346 4508
2133 1464
6751 6970
3123 6638
1754 1891
9758 7202
9459 1996
6866 4119
2365 2567
4770 1988
7773 8247
5784 1736
8808 9839
5030 1392
826 6086
2582 5952
3956 5233
5393 1856
2703 4192
7332 4132
4827 6583
5520 6211
6281 770
7610 2525
3213 7114
437 7952
915 9735
9...

output:

-1
4116
3838
-1
-1
-1
-1
2556
-1
-1
202
2782
474
4048
-1
3638
5260
3370
-1
-1
-1
3200
1756
-1
-1
-1
-1
-1
8820
640
330
-1
786
-1
-1
622
-1
-1
-1
34
7002
-1
-1
1822
-1
324
458
542
1128
4408
5068
-1
-1
-1
6308
-1
6090
-1
-1
-1
-1
3920
-1
1730
-1
942
2606
-1
6158
-1
-1
1828
882
-1
3056
-1
-1
-1
-1
-1
-...

result:

ok 100000 numbers

Test #36:

score: 0
Accepted
time: 112ms
memory: 55704kb

input:

2
9999
10000
100000
8098 3754
9078 1909
8185 1142
5077 6306
5181 86
1234 6462
7459 2407
7032 1291
1496 8951
4732 7693
6654 4748
554 6359
1437 6095
1048 5278
7219 3308
8905 1773
7970 3358
635 2750
7606 1787
9543 9943
5310 1949
6280 2906
2938 82
2471 2390
9004 6392
7435 9215
1073 7268
3345 748
4839 96...

output:

4344
-1
-1
-1
-1
5228
5052
-1
-1
-1
1906
-1
4658
4230
-1
7132
4612
-1
-1
400
-1
3374
2856
-1
2612
1780
-1
-1
-1
-1
-1
8040
6206
3152
-1
5212
-1
928
-1
-1
-1
-1
-1
-1
-1
2080
614
-1
356
602
-1
-1
-1
330
8580
-1
618
-1
4398
704
3336
510
1430
-1
6902
-1
3154
-1
80
3706
2690
-1
3220
-1
-1
2916
2996
-1
-...

result:

ok 100000 numbers