Submission #1175620

#TimeUsernameProblemLanguageResultExecution timeMemory
1175620sp2028Art Exhibition (JOI18_art)Java
Compilation error
0 ms0 KiB
import java.io.*;
import java.util.*;
public class AE {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        long N = Long.parseLong(br.readLine());
        long[][] artworks = new long[(int) N][2];
        for (int i = 0; i < N; i++) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            artworks[i][0] = Long.parseLong(st.nextToken()); 
            artworks[i][1] = Long.parseLong(st.nextToken());
        }
        Arrays.sort(artworks, Comparator.comparingLong(a -> a[0]));
        long max = Long.MIN_VALUE;
        int l = 0;
       long total = 0;
        for (int r = 0; r < N; r++) {
            total += artworks[r][1]; 
            while (l <= r && total < (artworks[r][0] - artworks[l][0])) {
                total -= artworks[l][1]; //update window
                l++;
            }
            max = Math.max(max, total - (artworks[r][0] - artworks[l][0]));//find the new max of the window
        }
        pw.println(max);
        pw.close();
    }
}

Compilation message (stderr)

art.java:3: error: class AE is public, should be declared in a file named AE.java
public class AE {
       ^
1 error

=======