Submission #1083780

#TimeUsernameProblemLanguageResultExecution timeMemory
1083780bvdArt Exhibition (JOI18_art)C++14
Compilation error
0 ms0 KiB
import java.util.Arrays; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.OutputStream; public class art { private static class Kattio extends PrintWriter { public Kattio(InputStream i) { super(new BufferedOutputStream(System.out)); r = new BufferedReader(new InputStreamReader(i)); } public Kattio(InputStream i, OutputStream o) { super(new BufferedOutputStream(o)); r = new BufferedReader(new InputStreamReader(i)); } public boolean hasMoreTokens() { return peekToken() != null; } public int getInt() { return Integer.parseInt(nextToken()); } public double getDouble() { return Double.parseDouble(nextToken()); } public long getLong() { return Long.parseLong(nextToken()); } public String getWord() { return nextToken(); } private BufferedReader r; private String line; private StringTokenizer st; private String token; private String peekToken() { if (token == null) try { while (st == null || !st.hasMoreTokens()) { line = r.readLine(); if (line == null) return null; st = new StringTokenizer(line); } token = st.nextToken(); } catch (IOException e) { } return token; } private String nextToken() { String ans = peekToken(); token = null; return ans; } } private static final class Artwork { public final long a; public final int b; public Artwork(long a, int b) { this.a = a; this.b = b; } } private static int clamp(long x) { if (x < 0) return -1; if (x > 0) return 1; return 0; } public static void main(String[] args) { try (Kattio io = new Kattio(System.in, System.out)) { int n = io.getInt(); Artwork[] artworks = new Artwork[n]; for (int i=0; i<n; ++i) { artworks[i] = new Artwork(io.getLong(), io.getInt()); } Arrays.sort(artworks, (t, o) -> clamp(t.a - o.a)); long[] f = new long[n+1]; f[0] = 0; long minSoFar = (long) 4e18; long result = 0; long prev = 0; for (int i=0; i<n; ++i) { long cur = prev + artworks[i].b; result = Math.max(result, artworks[i].b); long tmp = cur - artworks[i].a; result = Math.max(result, tmp - minSoFar); minSoFar = Math.min(minSoFar, prev - artworks[i].a); prev = cur; } io.println(result); } } }

Compilation message (stderr)

art.cpp:1:1: error: 'import' does not name a type
    1 | import java.util.Arrays;
      | ^~~~~~
art.cpp:2:1: error: 'import' does not name a type
    2 | import java.util.StringTokenizer;
      | ^~~~~~
art.cpp:3:1: error: 'import' does not name a type
    3 | import java.io.BufferedReader;
      | ^~~~~~
art.cpp:4:1: error: 'import' does not name a type
    4 | import java.io.BufferedOutputStream;
      | ^~~~~~
art.cpp:5:1: error: 'import' does not name a type
    5 | import java.io.IOException;
      | ^~~~~~
art.cpp:6:1: error: 'import' does not name a type
    6 | import java.io.InputStream;
      | ^~~~~~
art.cpp:7:1: error: 'import' does not name a type
    7 | import java.io.InputStreamReader;
      | ^~~~~~
art.cpp:8:1: error: 'import' does not name a type
    8 | import java.io.PrintWriter;
      | ^~~~~~
art.cpp:9:1: error: 'import' does not name a type
    9 | import java.io.OutputStream;
      | ^~~~~~
art.cpp:11:1: error: expected unqualified-id before 'public'
   11 | public class art {
      | ^~~~~~