Submission #991593


Source Code Expand

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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	boolean can(int max, int sum) {
		long total = (long)max * (max + 1) / 2;
		
		
		boolean ret = sum <= total;
		
		if (ret) {
			
			for (int i = max; i >= 1; i--) {
				if (sum >= i) {
					out.println(i);
					sum -= i;
				}
			}
			
		}
		
		return ret;
	}

	void solve() throws IOException {
		int n = nextInt();
		
		int ans = 1;
		while (true) {
			if (can(ans, n)) {
//				out.println(ans);
				return;
			}
			ans++;
		}
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Submission Info

Submission Time
Task B - Exactly N points
User mmaxio
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 1483 Byte
Status AC
Exec Time 156 ms
Memory 8912 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 95 ms 8144 KB
01-02.txt AC 156 ms 8276 KB
01-03.txt AC 93 ms 8144 KB
01-04.txt AC 95 ms 8148 KB
01-05.txt AC 95 ms 8144 KB
01-06.txt AC 94 ms 8148 KB
01-07.txt AC 93 ms 8276 KB
01-08.txt AC 95 ms 8016 KB
01-09.txt AC 94 ms 8148 KB
01-10.txt AC 94 ms 8144 KB
02-01.txt AC 102 ms 8528 KB
02-02.txt AC 115 ms 8656 KB
02-03.txt AC 113 ms 8660 KB
02-04.txt AC 103 ms 8528 KB
02-05.txt AC 117 ms 8912 KB
02-06.txt AC 140 ms 8404 KB
02-07.txt AC 109 ms 8404 KB
02-08.txt AC 113 ms 8656 KB
sample-01.txt AC 94 ms 8148 KB
sample-02.txt AC 93 ms 8144 KB
sample-03.txt AC 94 ms 8148 KB