Submission #9683145
Source Code Expand
/*
`
`
`
`
`
`
`
`
`!!!;' `
'%$@########################&&%:. `
.%###################################%. `
.`|######################################% `
.!@###############################################$' `
.!@#########################@@@#########################&;. `
:@##################@@@&&@@@$!!%&@@@@@@@###################&' `
:&################@@@&$%%||||!!:'':;!!||%|!%&@@#################%` `
|###############@@&&$%|!;;::::':'''':::;;!!|%%%$&&@###############$` `
:&#############@&$%||||!;'````````````'''```'':::'':!|$@@###############; `
:@#############@$$%|!;;;;:'``````...```...`...`'':::''';|%$$$&############&' `
|##############&$$$%||!!;:'`````..````....`...```''::::;!!||$&&@@###########&' `
!##############@$%|!!!;::'''`````...``.....`````````'''::::;;::!|%$&############| `
:@##########@&%!:'`::;;:'``....```....... .``....````````````'':;!|%$@############; `
;##########@%;```...`'''`... ..... ................ .`. `:!!!!%%%&#########| `
;##########&|:.`'`. ..`... ....... ..... .. ..... ... .'':!!:.`''!@#########|. `
!##########|'`.;!` . ...... .. . .... .::'`. .. .`'|@########@: `
;##########%'`'%! .. . . .. .```. ';:`..``.`':|@########@: `
!##########$:;$&; . `|%;. `;||;::`.``';;. .;!: `;:`';|$#########@!. `
!##########@$&@|. ...... .`':!|;` !$|%%'!##$' `|####$:`:;:!&$:. '$&!';!!||%&############; `
`$#############&: `!!'`:;;;||%@&!'!&&$;.|##%`.|#####%`'$@$&##%` .:||;;;;%@##############! `
:@#############|. .!&@|;%@@@@@&@@#@&@#@&@############@@#####@: .`'%@%!!&###############! `
:@############@; :&@!;$###@|%|!$@@######################@%` .;|!;!|%@###############! `
:@############@: `$#$%#@@##&@################@$$$&$%|!' `%#@|;':|&###############! `
!##########@$%: |####@&######$;. ..`'` ;@##############! `
!##########! ;#########|. `;` ;###############! `
;##########; `%######; '$###&: `%@############&' `
!########@: .'. .:;` .|%: !##########&' `
!########@: ;#########@: `
!######%. !##&;. . `%&!` '&###&' !#########! `
|#######;.%###! `!&###@|;;%@###%. ';;|&$:;;` |#%. .%###%$###! `
!#######| `%#&' |##&$####&: !##########; `%#####%.!#|. .%@: ;###;`%##! `
!#$!$##! :@#! .|###$'. ;##|. :&#@; .``::` ;@|. :@#@: `$#| `
:&&|&##; :&#! :&##; .%##! !&' ;@##! |#! `
|@@##@; .`%#! '$##; ;##$` :@! .|##@; :&! `
!&|&##%:'. :&! :@#%. .%##; |&!. `|@! `$! `
'$%%###&;. '&&' `%##&' |##@&: ...;&&&@; .;&#|':;$&: `
.|######&; '$@@@@@@@@#| :&######%` `
!#####&: '$#####@: `
'$#####@: ;#####$` `
'&####%. `` '$#####; `
!#####$' |@: .:%|;;;;!$#####@#| '&###$: `
:&####&: ;####################@: ':` `%###@: `
;#####@%:. `'';|@######$` `
`$######@|` !#&||@#####$` `
:&######@%'. .`''''` .';!|%@#@$$@####&: `
|######@|'. ;##$!!%@##########################@: '$####; `
:&#####$;''.`%#########&' `|@$: .%###@; `
:@####@; |#@##&$; `|%' .|####! `
!####@; . |####! `
:@###@|` . `|!. |####%. `
.|####! `;$@%|!!!!!%&&@#$;. !#####| `
.%####&: '%&@@@|` '&#####| `
.%#####|. :&######%` `
:|||;` !#######; .%#####@@#####@$;. `
`$#############&%!%#####|. :@####%:..'!&######@; `
`$#############|`..'%#######! ;####&;. .'%#######! `
.|##############@!` .'%#########%'. '%#####%` :@#######@%;:. `
;%|;. !############%::;' `!&############@&&@#######@%' !###########&' `
!################$' .:' '|&######################$:. :@#############@@@@@@; `
';$##&;:&###########$` :|$@################%:. !#####################@; `
'%####@$!:. `%#########! .:!%&@#######@%!;'. |##############%!$@####! `
.|#######&;'. . |#######%. .':;!!!!!!;`... .|############|. :$@@####%. `
!####&$&@#@!:'. ;#####%` .`';;'... ..''``. !##########%` ''':$######$` `
;#####@$$;`%&:. `%####; .:;;:'':;||!:` !#########! :&#@@####! `
'%######@######! !! :$@$` ...`.'::`.. '$######@!` '|$$&!!@#######@!. `
'$#########@&$$@######@: ;: . `' .... ...``. `$######&' '!;`'!@######&&########$' `
;############@#@@@@@$|%@###$` `!!.;' . :!. .%#####!. .;::&####|`..` ..;@########!'
|########&|;'``..`:' ..!##%:. ;; `. .|###|` `'|###@&$|` .. .`|&&@#######%:
|###@#@@#&|:`.`';;:;!!!;:;''!$##&;'. .'%; .;&###&|$! '$; .|$:;|` ...;&###$' .... :||%&########%:
|#######@$;!%%:``` .!@###&|` :|'!########@#! ;@! :@####%'. `|@###&: ..`:::%$$&$$$&@##@@@##|:
|########$;::'` .`. `%#####%!: .. !#####%` !#%. !; '%; !#############&: `::`.```. .':. :$@&&&###|:
!####@%:::;;:::::` ......... '. !#######%;;';; `%#&' ;&: `;``$@!%########&&##&|::::'. ':. `!%@@######|:
!#####%;;::. ...... ....`.. .. '::!|&########$';%`.'` .;%: !#$';$%|&$!&##########$' `';;;;!&##&%||||||%;` .:|&###@###|:
|#######|`... `|$&&$$!`.... ;$: :&#@: `'''``. .%########&' .%#@&$%$#####$` ....`:%&@@@@@@&&@@!`. .`'%@#######|'
|######@@$: .`..`!@&$&&&&: ;@#######@@#$%@######&$; '%@##%!@###@&&@####%. `!&@@@@@$:..`..``.``... `|&####@@##!'
;###&|;::!&#&%%%%: .'::::;|$&&$%|'..;%%&#######%;$########@&#####%` '|@###; '%####$;::::::` '!|%%%%%%%%%&#$:'::.'%###|'
`%###@|;|%$%$@#&|;::::` '|%%%%%$%|%|;';$##@|'. |######&' .:|$%: :&@|'. !####%. `::;:!$@######&%%%%%!' ':;&##|:
'$##%:. :&##@####@$;. .. `$| :; !#####| '|%: `` ... !####! . ..:&#@@@@##@&||$; :&####|'
!####&@@&; ...`.'%@##@@#@@&!` :&&!. !###&' :||:.` !%' ``:$######@@@&&@@@&@##$;``.... |@@@@########!'
!#######@$||!: ';!;;;!&###&|||||||||||%&##@!`. !###&||%!!!: .:;` `;;%####$;:;;;;;;;;;;;::. '||||||&#####%!;;$##!`
`%#&:.`:!||||||%@#@%;::;;;' ;@@: .. .%###|. `:::' .:!;'`':'` `$####! ':;;;;!%@@&%%%|;` `;%&###|:
.%##|.. '$##@@@@@@#&:...`.. `$#$' !##%` ..`.`:%@@! '%@$:''. .`|####|... .........`:%###@#@@@|` ....`%#####|:
!###@&! .`.```':!&##@&&&&$: '&#%. !#&' ````. .```:%&&&&&@#####@!':|$&&$&&&&&&&&&@##|`````. !@@@#######!'
:&#########@$||||: `::::;;;;;!!;;;:;$###$' .'` |#@|. .:;;:. `%####%:''':::::` `!||&##$;;;:::. ;##|:
.%#@$%$%%%%%$@###$::::::'. ...`;|!::!&##@$%|||!' .%##&%%$%' `'. :&####! .':::'::%@&$%%!` .!!':;$###%:
:&#############@|. . '$##################&;..!@###@#######%'. .!#####! . `$#####@|``;&|!&####|:
|####&%' .''''':|@###@$$$$$$%;. |####%` .|#@;. .;$$$%$&$$$$$$&######$:..:|%$$$$$$$&&&&@######&;'''. ;$&########|:
|#######@%;;` '!|!||$#######&|!!!;;;!!!;`.!#####@: .;|!!|&#$' `:'':;;$######################################%!|!!!!!;. .`;|&######@####%:
|############$!''''..';$&&&&@########################$;'!;`:@#&:``'|$@######@@@@&&&&&&&@#######@&&&&&&&&&&&@@&&&&$|:. .`''$########@&@####%:
|###&%$&#################@%;' .. `|@############$: `%@###########$` `%%:. . :@######| !#####################@$%&##########%:
|#######################################@&&@######################@@&@#######################################################################%:
*/
#define _CRT_SECURE_NO_WARNINGS
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
namespace pufanyi {
inline char gc() {
static const int L = 233333;
static char sxd[L], *sss = sxd, *ttt = sxd;
if (sss == ttt) {
ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
if (sss == ttt) {
return EOF;
}
}
return *sss++;
}
#ifndef _AT_HOME
#define dd c = gc()
#else
#define dd c = getchar()
#endif
inline char readalpha() {
char dd;
for (; !isalpha(c); dd);
return c;
}
inline char readchar() {
char dd;
for (; c == ' '; dd);
return c;
}
template <class T>
inline bool read(T& x) {
bool flg = false;
char dd;
x = 0;
for (; !isdigit(c); dd) {
if (c == '-') {
flg = true;
} else if(c == EOF) {
return false;
}
}
for (; isdigit(c); dd) {
x = (x << 1) + (x << 3) + (c ^ 48);
}
if (flg) {
x = -x;
}
return true;
}
#undef dd
template <class T>
inline void write(T x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x < 10) {
putchar(x | 48);
return;
}
write(x / 10);
putchar((x % 10) | 48);
}
template <class T>
inline void writesp(T x) {
write(x);
putchar(' ');
}
template <class T>
inline void writeln(T x) {
write(x);
puts("");
}
typedef long long LL;
const int maxn = 200005;
int n, m;
int aa[maxn];
inline bool check(int x) {
int lim = x << 1;
for (int l = lim + 1, r = n << 1; l < r; ++l, --r) {
if (aa[l] + aa[r] < m) {
return false;
}
}
return true;
}
int Main() {
read(n), read(m);
for (int i = 1; i <= n << 1; ++i) {
read(aa[i]);
}
sort(aa + 1, aa + (n << 1) + 1);
int l = 0, r = n;
while (l < r) {
int mid = (l + r) >> 1;
if (check(mid)) {
r = mid;
} else {
l = mid + 1;
}
}
int ans = 0;
int lim = l << 1;
// cout << "lim = " << lim << endl;
for (int l = 1, r = lim; l < r; ++l, --r) {
ans = max(ans, (aa[l] + aa[r]) % m);
}
for (int l = lim + 1, r = n << 1; l < r; ++l, --r) {
ans = max(ans, (aa[l] + aa[r]) % m);
}
writeln(ans);
return 0;
}
}
int main() {
return pufanyi::Main();
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Modulo Pairing |
| User | pufanyi |
| Language | C++14 (GCC 5.4.1) |
| Score | 1200 |
| Code Size | 17868 Byte |
| Status | AC |
| Exec Time | 21 ms |
| Memory | 1408 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1200 / 1200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 0_00.txt, 0_01.txt |
| All | 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_00.txt | AC | 1 ms | 256 KiB |
| 0_01.txt | AC | 1 ms | 256 KiB |
| 1_00.txt | AC | 1 ms | 256 KiB |
| 1_01.txt | AC | 5 ms | 1280 KiB |
| 1_02.txt | AC | 1 ms | 256 KiB |
| 1_03.txt | AC | 1 ms | 256 KiB |
| 1_04.txt | AC | 1 ms | 256 KiB |
| 1_05.txt | AC | 5 ms | 1280 KiB |
| 1_06.txt | AC | 5 ms | 1280 KiB |
| 1_07.txt | AC | 5 ms | 1280 KiB |
| 1_08.txt | AC | 7 ms | 1280 KiB |
| 1_09.txt | AC | 8 ms | 1280 KiB |
| 1_10.txt | AC | 10 ms | 1280 KiB |
| 1_11.txt | AC | 10 ms | 1280 KiB |
| 1_12.txt | AC | 11 ms | 1280 KiB |
| 1_13.txt | AC | 21 ms | 1280 KiB |
| 1_14.txt | AC | 3 ms | 512 KiB |
| 1_15.txt | AC | 21 ms | 1280 KiB |
| 1_16.txt | AC | 3 ms | 512 KiB |
| 1_17.txt | AC | 20 ms | 1280 KiB |
| 1_18.txt | AC | 3 ms | 512 KiB |
| 1_19.txt | AC | 20 ms | 1280 KiB |
| 1_20.txt | AC | 3 ms | 512 KiB |
| 1_21.txt | AC | 21 ms | 1280 KiB |
| 1_22.txt | AC | 3 ms | 512 KiB |
| 1_23.txt | AC | 21 ms | 1280 KiB |
| 1_24.txt | AC | 3 ms | 512 KiB |
| 1_25.txt | AC | 20 ms | 1280 KiB |
| 1_26.txt | AC | 3 ms | 512 KiB |
| 1_27.txt | AC | 21 ms | 1280 KiB |
| 1_28.txt | AC | 3 ms | 512 KiB |
| 1_29.txt | AC | 20 ms | 1280 KiB |
| 1_30.txt | AC | 3 ms | 512 KiB |
| 1_31.txt | AC | 19 ms | 1280 KiB |
| 1_32.txt | AC | 3 ms | 512 KiB |
| 1_33.txt | AC | 21 ms | 1280 KiB |
| 1_34.txt | AC | 3 ms | 512 KiB |
| 1_35.txt | AC | 21 ms | 1280 KiB |
| 1_36.txt | AC | 3 ms | 512 KiB |
| 1_37.txt | AC | 20 ms | 1280 KiB |
| 1_38.txt | AC | 3 ms | 512 KiB |
| 1_39.txt | AC | 20 ms | 1280 KiB |
| 1_40.txt | AC | 3 ms | 512 KiB |
| 1_41.txt | AC | 20 ms | 1408 KiB |
| 1_42.txt | AC | 3 ms | 512 KiB |
| 1_43.txt | AC | 20 ms | 1280 KiB |
| 1_44.txt | AC | 3 ms | 512 KiB |
| 1_45.txt | AC | 19 ms | 1280 KiB |
| 1_46.txt | AC | 3 ms | 512 KiB |
| 1_47.txt | AC | 21 ms | 1280 KiB |
| 1_48.txt | AC | 3 ms | 512 KiB |
| 1_49.txt | AC | 21 ms | 1280 KiB |
| 1_50.txt | AC | 3 ms | 512 KiB |
| 1_51.txt | AC | 20 ms | 1280 KiB |
| 1_52.txt | AC | 3 ms | 512 KiB |
| 1_53.txt | AC | 21 ms | 1280 KiB |
| 1_54.txt | AC | 3 ms | 512 KiB |
| 1_55.txt | AC | 20 ms | 1280 KiB |
| 1_56.txt | AC | 3 ms | 512 KiB |