Submission #1986422


Source Code Expand

public class Main {

	private static void solve() {
		int n = ni();
		
		int ng = 0;
		int ok = n;
		while (Math.abs(ok - ng) > 1) {
			int k = (ng + ok ) / 2;
			
			
			int now = n;
			for (int i = k; i >= 1; i --) {
				if (now >= i) {
					now -= i;
				}
			}
			if (now == 0) {
				ok = k;
			} else {
				ng = k;
			}
		}
		int now = n;
		for (int i = ok; i >= 1; i --) {
			if (now >= i) {
				now -= i;
				System.out.println(i);
			}
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}

Submission Info

Submission Time
Task B - Exactly N points
User hiromi_ayase
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 2729 Byte
Status AC
Exec Time 148 ms
Memory 22356 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 3
AC × 13
AC × 24
Set Name Test Cases
sample sample-01.txt, sample-02.txt, sample-03.txt
dataset1 sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
dataset2 sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt AC 71 ms 19280 KB
01-02.txt AC 71 ms 18132 KB
01-03.txt AC 70 ms 19028 KB
01-04.txt AC 71 ms 19156 KB
01-05.txt AC 70 ms 17492 KB
01-06.txt AC 71 ms 19156 KB
01-07.txt AC 70 ms 20308 KB
01-08.txt AC 72 ms 19412 KB
01-09.txt AC 72 ms 18516 KB
01-10.txt AC 72 ms 19284 KB
02-01.txt AC 142 ms 22224 KB
02-02.txt AC 138 ms 22356 KB
02-03.txt AC 136 ms 20436 KB
02-04.txt AC 147 ms 22100 KB
02-05.txt AC 148 ms 20180 KB
02-06.txt AC 117 ms 20436 KB
02-07.txt AC 111 ms 22228 KB
02-08.txt AC 146 ms 19540 KB
sample-01.txt AC 69 ms 19412 KB
sample-02.txt AC 69 ms 19284 KB
sample-03.txt AC 71 ms 20692 KB