Submission #991554


Source Code Expand

import java.io.*;
import java.util.*;

public class Main {
	FastScanner in;
	PrintWriter out;

	void solve() {
		int n = in.nextInt();
		int sum = 0;
		for (int x = 1;; x++) {
			sum += x;
			if (sum >= n) {
				for (int i = x; i >= 1; i--) {
					if (n >= i) {
						out.println(i);
						n -= i;
					}
				}
				return;
			}
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Submission Info

Submission Time
Task B - Exactly N points
User qwerty787788
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 2041 Byte
Status AC
Exec Time 318 ms
Memory 9092 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 3
AC × 13
AC × 21
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
Case Name Status Exec Time Memory
01-01.txt AC 99 ms 8432 KB
01-02.txt AC 98 ms 8432 KB
01-03.txt AC 97 ms 8428 KB
01-04.txt AC 98 ms 8400 KB
01-05.txt AC 97 ms 8400 KB
01-06.txt AC 98 ms 8452 KB
01-07.txt AC 97 ms 8400 KB
01-08.txt AC 97 ms 8428 KB
01-09.txt AC 96 ms 8428 KB
01-10.txt AC 100 ms 8400 KB
02-01.txt AC 119 ms 9092 KB
02-02.txt AC 121 ms 9092 KB
02-03.txt AC 318 ms 8868 KB
02-04.txt AC 120 ms 8872 KB
02-05.txt AC 119 ms 8868 KB
02-06.txt AC 102 ms 8660 KB
02-07.txt AC 102 ms 8556 KB
02-08.txt AC 106 ms 8684 KB
sample-01.txt AC 96 ms 8432 KB
sample-02.txt AC 105 ms 8324 KB
sample-03.txt AC 106 ms 8452 KB