Submission #1412488


Source Code Expand

Copy
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveC();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		int[] sum = new int[N + 1];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			sum[A[i]]++;
		}
		int[] X = new int[M];
		int[] Y = new int[M];
		for (int i = 0; i < M; i++) {
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		for (int i = 0; i < M; i++) {
			sum[A[X[i] - 1]]--;
			A[X[i] - 1] = Y[i];
			sum[Y[i]]++;
			int current = 0;
			int num = 0;
			for (int j = N; j > 0; j--) {
				if (current < sum[j]) {
					current = sum[j];
				}
				if (current > 0) {
					current--;
				} else {
					num++;
				}
			}
			System.out.println(num);
		}
	}
}

Submission Info

Submission Time
Task C - Snuke and Spells
User schwarzahl
Language Java8 (OpenJDK 1.8.0)
Score 500
Code Size 885 Byte
Status
Exec Time 2109 ms
Memory 159168 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
subtask 500 / 500 sample1.txt, sample2.txt, sample3.txt, subtask_a1.txt, subtask_a2.txt, subtask_a3.txt, subtask_a4.txt, subtask_a5.txt, subtask_a6.txt, subtask_b1.txt, subtask_b2.txt, subtask_c1.txt, subtask_c2.txt, subtask_d1.txt, subtask_d2.txt, subtask_d3.txt, subtask_d4.txt, subtask_e1.txt, subtask_e2.txt, subtask_e3.txt, subtask_e4.txt, subtask_f1.txt, subtask_f2.txt
All 0 / 500 sample1.txt, sample2.txt, sample3.txt, a1.txt, a2.txt, a3.txt, a4.txt, a5.txt, a6.txt, b1.txt, b2.txt, c1.txt, c2.txt, d1.txt, d2.txt, d3.txt, d4.txt, e1.txt, e2.txt, e3.txt, e4.txt, f1.txt, f2.txt, sample1.txt, sample2.txt, sample3.txt, subtask_a1.txt, subtask_a2.txt, subtask_a3.txt, subtask_a4.txt, subtask_a5.txt, subtask_a6.txt, subtask_b1.txt, subtask_b2.txt, subtask_c1.txt, subtask_c2.txt, subtask_d1.txt, subtask_d2.txt, subtask_d3.txt, subtask_d4.txt, subtask_e1.txt, subtask_e2.txt, subtask_e3.txt, subtask_e4.txt, subtask_f1.txt, subtask_f2.txt
Case Name Status Exec Time Memory
a1.txt 2109 ms 154108 KB
a2.txt 2109 ms 159168 KB
a3.txt 2109 ms 150508 KB
a4.txt 2109 ms 153104 KB
a5.txt 2109 ms 152740 KB
a6.txt 2105 ms 153508 KB
b1.txt 2109 ms 152020 KB
b2.txt 2109 ms 155184 KB
c1.txt 2109 ms 157100 KB
c2.txt 2109 ms 153272 KB
d1.txt 2105 ms 153340 KB
d2.txt 2105 ms 151992 KB
d3.txt 2105 ms 153072 KB
d4.txt 2109 ms 152508 KB
e1.txt 2109 ms 153220 KB
e2.txt 2109 ms 152764 KB
e3.txt 2109 ms 153520 KB
e4.txt 2109 ms 152792 KB
f1.txt 2109 ms 154712 KB
f2.txt 2109 ms 154212 KB
sample1.txt 90 ms 19796 KB
sample2.txt 92 ms 18516 KB
sample3.txt 93 ms 23764 KB
subtask_a1.txt 129 ms 22996 KB
subtask_a2.txt 119 ms 20052 KB
subtask_a3.txt 131 ms 20180 KB
subtask_a4.txt 130 ms 22868 KB
subtask_a5.txt 137 ms 23516 KB
subtask_a6.txt 130 ms 21076 KB
subtask_b1.txt 133 ms 19924 KB
subtask_b2.txt 130 ms 21124 KB
subtask_c1.txt 133 ms 21548 KB
subtask_c2.txt 141 ms 23024 KB
subtask_d1.txt 138 ms 23504 KB
subtask_d2.txt 123 ms 19028 KB
subtask_d3.txt 129 ms 25348 KB
subtask_d4.txt 139 ms 20300 KB
subtask_e1.txt 121 ms 19796 KB
subtask_e2.txt 118 ms 23252 KB
subtask_e3.txt 136 ms 21036 KB
subtask_e4.txt 121 ms 19984 KB
subtask_f1.txt 126 ms 20948 KB
subtask_f2.txt 131 ms 20308 KB