結果
問題 | No.1465 Archaea |
ユーザー | threepipes_s |
提出日時 | 2021-04-02 22:10:27 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 2,555 bytes |
コンパイル時間 | 2,346 ms |
コンパイル使用メモリ | 78,844 KB |
実行使用メモリ | 50,864 KB |
最終ジャッジ日時 | 2024-06-06 10:32:44 |
合計ジャッジ時間 | 4,204 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
50,184 KB |
testcase_01 | AC | 53 ms
49,904 KB |
testcase_02 | AC | 54 ms
50,296 KB |
testcase_03 | AC | 54 ms
49,968 KB |
testcase_04 | AC | 52 ms
50,192 KB |
testcase_05 | AC | 53 ms
50,228 KB |
testcase_06 | AC | 53 ms
50,088 KB |
testcase_07 | AC | 57 ms
50,084 KB |
testcase_08 | AC | 54 ms
50,136 KB |
testcase_09 | AC | 59 ms
50,004 KB |
testcase_10 | AC | 55 ms
50,184 KB |
testcase_11 | AC | 59 ms
50,300 KB |
testcase_12 | AC | 53 ms
49,920 KB |
testcase_13 | AC | 69 ms
50,864 KB |
testcase_14 | AC | 60 ms
50,272 KB |
testcase_15 | AC | 53 ms
50,380 KB |
testcase_16 | AC | 53 ms
50,072 KB |
testcase_17 | AC | 80 ms
50,848 KB |
testcase_18 | AC | 52 ms
50,372 KB |
testcase_19 | AC | 57 ms
50,248 KB |
testcase_20 | AC | 60 ms
50,084 KB |
testcase_21 | AC | 76 ms
50,664 KB |
testcase_22 | AC | 65 ms
50,828 KB |
testcase_23 | AC | 51 ms
50,296 KB |
ソースコード
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.*; public class Main { static ContestScanner in;static Writer out;static StringBuilder sb=new StringBuilder(); public static void main(String[] args) {try{in=new ContestScanner();out=new Writer();Main solve=new Main();solve.solve(); in.close();out.flush();out.close();}catch(IOException e){e.printStackTrace();}} void solve() throws NumberFormatException, IOException{ int n = in.nextInt(); int k = in.nextInt(); int[] dp = new int[n + 1]; Arrays.fill(dp, Integer.MAX_VALUE); dp[1] = 0; for (int i = 1; i < n; i++) { if (dp[i] >= k) continue; if (i * 2 <= n) dp[i * 2] = Math.min(dp[i * 2], dp[i] + 1); if (i + 3 <= n) dp[i + 3] = Math.min(dp[i + 3], dp[i] + 1); } System.out.println(dp[n] <= k ? "YES" : "NO"); } } class Writer extends PrintWriter{ public Writer(String filename)throws IOException {super(new BufferedWriter(new FileWriter(filename)));} public Writer()throws IOException{super(System.out);} } class ContestScanner implements Closeable{ private BufferedReader in;private int c=-2; public ContestScanner()throws IOException {in=new BufferedReader(new InputStreamReader(System.in));} public ContestScanner(String filename)throws IOException {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));} public String nextToken()throws IOException { StringBuilder sb=new StringBuilder(); while((c=in.read())!=-1&&Character.isWhitespace(c)); while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();} return sb.toString(); } public String readLine()throws IOException{ StringBuilder sb=new StringBuilder();if(c==-2)c=in.read(); while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();} return sb.toString(); } public long nextLong()throws IOException,NumberFormatException {return Long.parseLong(nextToken());} public int nextInt()throws NumberFormatException,IOException {return(int)nextLong();} public double nextDouble()throws NumberFormatException,IOException {return Double.parseDouble(nextToken());} public void close() throws IOException {in.close();} }