hiho week 224 register

Ended

Participants:153

Verdict:Accepted
Score:100 / 100
Submitted:2018-10-14 14:08:24

Lang:Java

Edit
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
31
import java.util.*;
public class Main {
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a[] = new int[100001];
        int t = sc.nextInt();
        while(t-- != 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            Arrays.fill(a0);
            for (int i = 0i < ni++) {
                a[sc.nextInt()]++;
            }
            Boolean yes = true;
            for(int i = 1i < 100001 && yes && n > 0i++) {
                if (a[i!= 0) {
                    int m = a[i];
                    for (int j = ij < i + kj++){
                        //System.out.println("i j:" + i + " " + j + " " + a[i] + " " + a[j]);
                        if (m > a[j]) {
                            yes = false;
                            break;
                        }
                        a[j-= m;
                        n -= m;
                    }
                }
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX