cf/mirror

Farmer John's Favorite Function

CF
1942F2700· international gm5s256 MB⌨ stdin/stdout

Examples

Sample 1of 4
Input
5 6
0 14 0 7 6
1 4
1 3
2 15
4 1
5 2
5 8
Output
3
2
3
2
1
3
Sample 2of 4
Input
15 10
3364 1623 5435 7 6232 245 7903 3880 9738 577 4598 1868 1112 8066 199
14 4284
14 8066
6 92
6 245
2 925
2 1623
5 176
5 6232
3 1157
3 5435
Output
16
17
16
17
16
17
16
17
16
17
Sample 3of 4
Input
2 2
386056082462833225 923951085408043421
1 386056082462833225
1 386056082462833224
Output
961223744
961223743
Sample 4of 4
Input
13 10
31487697732100 446330174221392699 283918145228010533 619870471872432389 11918456891794188 247842810542459080 140542974216802552 698742782599365547 533363381213535498 92488084424940128 401887157851719898 128798321287952855 137376848358184069
3 283918145228010532
3 283918145228010533
1 2183728930312
13 1000000000000000000
10 1000000000000000000
9 1000000000000000000
8 1000000000000000000
7 1000000000000000000
6 1000000000000000000
5 1000000000000000000
Output
370643829
370643830
370643829
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1942F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)