Submission #1606736


Source Code Expand

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		
		Queue<PosT> queue = new LinkedList<>();
		queue.add(new PosT(0,0));
		while(queue.size() > 0){
			PosT cur = queue.remove();
			if(cur.pos == x){
				System.out.println(cur.time);
				return;
			}
			queue.add(new PosT(cur.pos+cur.time+1,cur.time+1));
			queue.add(new PosT(cur.pos-cur.time-1,cur.time+1));
			queue.add(new PosT(cur.pos,cur.time+1));
		}
	}
}

class PosT{
	public int pos;
	public int time;
	
	public PosT(int _pos, int _time){
		pos = _pos;
		time = _time;
	}
}

Submission Info

Submission Time
Task C - Go Home
User vjudge1
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 649 Byte
Status TLE
Exec Time 2111 ms
Memory 312164 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 3
AC × 4
TLE × 14
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt
Case Name Status Exec Time Memory
0_000.txt AC 90 ms 21716 KB
0_001.txt AC 90 ms 19796 KB
0_002.txt AC 91 ms 21844 KB
1_003.txt TLE 2110 ms 310036 KB
1_004.txt TLE 2111 ms 312164 KB
1_005.txt AC 91 ms 20564 KB
1_006.txt TLE 2110 ms 295224 KB
1_007.txt TLE 2111 ms 297728 KB
1_008.txt TLE 2111 ms 305280 KB
1_009.txt TLE 2111 ms 309380 KB
1_010.txt TLE 2111 ms 308844 KB
1_011.txt TLE 2111 ms 301164 KB
1_012.txt TLE 2111 ms 307740 KB
1_013.txt TLE 2111 ms 288020 KB
1_014.txt TLE 2111 ms 294648 KB
1_015.txt TLE 2111 ms 307024 KB
1_016.txt TLE 2110 ms 310532 KB
1_017.txt TLE 2111 ms 308448 KB