Submission #281985

# Submission time Handle Problem Language Result Execution time Memory
281985 2020-08-23T18:26:43 Z FlashGamezzz Art Exhibition (JOI18_art) Java 11
Compilation error
0 ms 0 KB
static int n;
	static long[] max = new long[1100000], upd = new long[1100000];
	static void upd(int l, int u, long d) {
		upd(0, 0, n-1, l, u, d);
	}
	static void upd(int i, int s, int e, int l, int u, long d) {
		if (upd[i] != 0) { 
			max[i] += upd[i];
			if (s != e) { 
				upd[i * 2 + 1] += upd[i]; 
				upd[i * 2 + 2] += upd[i]; 
			}
			upd[i] = 0;
		} 
		if (s > e || s > u || e < l) {
			return; 
		}
		if (s >= l && e <= u) { 
			max[i] += d;
			if (s != e) { 
				upd[i * 2 + 1] += d; 
				upd[i * 2 + 2] += d; 
			} 
			return; 
		}  
		upd(i * 2 + 1, s, (s + e)/2, l, u, d); 
		upd(i * 2 + 2, (s + e)/2 + 1, e, l, u, d); 
		max[i] = Long.max(max[i * 2 + 1], max[i * 2 + 2]);
	}
	static long max(int l, int u) {
		return max(0, 0, n-1, l, u);
	}
	static long max(int i, int s, int e, int l, int u) {
		if (upd[i] != 0) { 
			max[i] += upd[i];
			if (s != e) { 
				upd[i * 2 + 1] += upd[i]; 
				upd[i * 2 + 2] += upd[i]; 
			}
			upd[i] = 0;
		}
		if (s > e || s > u || e < l) {
			return Long.MIN_VALUE; 
		}
		if (s >= l && e <= u) { 
			return max[i]; 
		}
		return Long.max(max(2*i+1, s, (s+e)/2, l, u), max(2*i+2, (s+e)/2+1, e, l, u)); 
	}
	static class art implements Comparable<art>{
		int a;
		long s;
		art (int x, long y) {
			a = x;
			s = y;
		}
		public int compareTo(art o) {
			if (s < o.s) {
				return -1;
			}
			if (s == o.s) {
				return 0;
			}
			return 1;
		}
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		n = Integer.parseInt(br.readLine());
		PriorityQueue<art> pq = new PriorityQueue<art>();
		for (int i = 0; i < n; i++) {
			String[] line = br.readLine().split(" ");
			pq.add(new art(Integer.parseInt(line[1]), Long.parseLong(line[0])));
		}
		long size = pq.peek().s;
		long ans = 0;
		for (int i = 0; i < n; i++) {
			art c = pq.poll();
			upd(0, i, size-c.s);
			upd(0, i, c.a);
			ans = Long.max(ans, max(0, i));
			size = c.s;
		}
		pw.println(ans);
		pw.close();
	}

Compilation message

art.java:1: error: class, interface, or enum expected
static int n;
       ^
art.java:2: error: class, interface, or enum expected
	static long[] max = new long[1100000], upd = new long[1100000];
	       ^
art.java:3: error: class, interface, or enum expected
	static void upd(int l, int u, long d) {
	       ^
art.java:5: error: class, interface, or enum expected
	}
	^
art.java:9: error: class, interface, or enum expected
			if (s != e) { 
			^
art.java:11: error: class, interface, or enum expected
				upd[i * 2 + 2] += upd[i]; 
				^
art.java:12: error: class, interface, or enum expected
			}
			^
art.java:14: error: class, interface, or enum expected
		} 
		^
art.java:17: error: class, interface, or enum expected
		}
		^
art.java:20: error: class, interface, or enum expected
			if (s != e) { 
			^
art.java:22: error: class, interface, or enum expected
				upd[i * 2 + 2] += d; 
				^
art.java:23: error: class, interface, or enum expected
			} 
			^
art.java:25: error: class, interface, or enum expected
		}  
		^
art.java:27: error: class, interface, or enum expected
		upd(i * 2 + 2, (s + e)/2 + 1, e, l, u, d); 
		^
art.java:28: error: class, interface, or enum expected
		max[i] = Long.max(max[i * 2 + 1], max[i * 2 + 2]);
		^
art.java:29: error: class, interface, or enum expected
	}
	^
art.java:32: error: class, interface, or enum expected
	}
	^
art.java:36: error: class, interface, or enum expected
			if (s != e) { 
			^
art.java:38: error: class, interface, or enum expected
				upd[i * 2 + 2] += upd[i]; 
				^
art.java:39: error: class, interface, or enum expected
			}
			^
art.java:41: error: class, interface, or enum expected
		}
		^
art.java:44: error: class, interface, or enum expected
		}
		^
art.java:47: error: class, interface, or enum expected
		}
		^
art.java:49: error: class, interface, or enum expected
	}
	^
art.java:67: error: class, interface, or enum expected
	public static void main(String[] args) throws IOException {
	              ^
art.java:69: error: class, interface, or enum expected
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		^
art.java:70: error: class, interface, or enum expected
		n = Integer.parseInt(br.readLine());
		^
art.java:71: error: class, interface, or enum expected
		PriorityQueue<art> pq = new PriorityQueue<art>();
		^
art.java:72: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		^
art.java:72: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		                ^
art.java:72: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		                       ^
art.java:74: error: class, interface, or enum expected
			pq.add(new art(Integer.parseInt(line[1]), Long.parseLong(line[0])));
			^
art.java:75: error: class, interface, or enum expected
		}
		^
art.java:77: error: class, interface, or enum expected
		long ans = 0;
		^
art.java:78: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		^
art.java:78: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		                ^
art.java:78: error: class, interface, or enum expected
		for (int i = 0; i < n; i++) {
		                       ^
art.java:80: error: class, interface, or enum expected
			upd(0, i, size-c.s);
			^
art.java:81: error: class, interface, or enum expected
			upd(0, i, c.a);
			^
art.java:82: error: class, interface, or enum expected
			ans = Long.max(ans, max(0, i));
			^
art.java:83: error: class, interface, or enum expected
			size = c.s;
			^
art.java:84: error: class, interface, or enum expected
		}
		^
art.java:86: error: class, interface, or enum expected
		pw.close();
		^
art.java:87: error: class, interface, or enum expected
	}
	^
44 errors