[Offer收割]编程练习赛32 register

Ended

Participants:237

Verdict:Time Limit Exceeded
Score:60 / 100
Submitted:2017-10-22 13:47:52

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.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Drop> ls = new ArrayList<Drop>();
        for (int i=0;i<k;i++){
            Drop thisD = new Drop();
            thisD.x = sc.nextInt();
            thisD.y = sc.nextInt();
            thisD.depth = sc.nextInt();
            ls.add(thisD);
        }
        
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                int max = 0;
                for (int a=0;a<k;a++){
                    Drop d = ls.get(a);
                    int this_dep = d.depth-Math.abs(d.x-i)-Math.abs(d.y-j);
                    if (this_dep > max){
                        max = this_dep;
                    }
                }
                System.out.print(max+ " ");
            }
            System.out.println("");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX