F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

pog loves szh II

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 3427    Accepted Submission(s): 949


Problem Description
Pog and Szh are playing games.There is a sequence with $n$ numbers, Pog will choose a number A from the sequence. Szh will choose an another number named B from the rest in the sequence. Then the score will be $(A+B)$ mod $p$.They hope to get the largest score.And what is the largest score?
 

Input
Several groups of data (no more than $5$ groups,$n \geq 1000$).

For each case:

The following line contains two integers,$n(2 \leq n \leq 100000)$£¬$p(1 \leq p \leq 2^{31}-1)$¡£

The following line contains $n$ integers $a_i(0 \leq a_i \leq 2^{31}-1)$¡£
 

Output
For each case,output an integer means the largest score.
 

Sample Input
4 4 1 2 3 0 4 4 0 0 2 2
 

Sample Output
3 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-24 22:44:59, Gzip enabled