답안 #1083773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083773 2024-09-04T06:12:17 Z bvd Art Exhibition (JOI18_art) Java 11
컴파일 오류
0 ms 0 KB
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 record Artwork(long a, int b) {
		
	}

	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) -> Math.clamp(t.a - o.a, -1, 1));
			long[] f = new long[n+1];
			f[0] = 0;
			for (int i=0; i<n; ++i) {
				f[i+1] = f[i] + artworks[i].b;
			}
			
			long minSoFar = -artworks[0].a;
			long result = 0;
			for (int i=0; i<n; ++i) {
				result = Math.max(result, artworks[i].b);
				long tmp = f[i+1] - artworks[i].a;
				result = Math.max(result, tmp - minSoFar);
				minSoFar = Math.min(minSoFar, tmp);
			}
			
			io.println(result);
		}
	}
}

Compilation message

art.java:70: error: cannot find symbol
	private static record Artwork(long a, int b) {
	               ^
  symbol:   class record
  location: class art
art.java:77: error: cannot find symbol
			Artwork[] artworks = new Artwork[n];
			^
  symbol:   class Artwork
  location: class art
art.java:77: error: cannot find symbol
			Artwork[] artworks = new Artwork[n];
			                         ^
  symbol:   class Artwork
  location: class art
art.java:79: error: cannot find symbol
				artworks[i] = new Artwork(io.getLong(), io.getInt());
				                  ^
  symbol:   class Artwork
  location: class art
4 errors