Submission #60086
Source Code Expand
import java.util.Arrays; public class Main { void run() { Scanner sc = new Scanner(); int n = sc.nextInt(); char[] s = sc.nextLine().toCharArray(); int[] dp = new int[n]; Arrays.fill(dp, 10000); dp[0] = 0; for(int i=1;i<n;i++){ int min = 10000; for(int j=1;j<=3;j++){ if(i-j<0)break; min = Math.min(min, dp[i-j]); } dp[i] = min; if(s[i]=='X')dp[i]++; } System.out.println(dp[n-1]); } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } class Scanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } long nextLong() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextLong(); long res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } String nextLine(){ try{ StringBuilder res =new StringBuilder(""); int c = System.in.read(); while (c=='\r' || c=='\n') c = System.in.read(); do { res.append((char) c); c = System.in.read(); } while (c!='\r' && c!='\n'); return res.toString(); }catch (Exception e) { return null; } } } public static void main(String... args) { new Main().run(); } }
Submission Info
Submission Time | |
---|---|
Task | B - 雨上がり |
User | nanikaka |
Language | Java (OpenJDK 1.7.0) |
Score | 50 |
Code Size | 2242 Byte |
Status | AC |
Exec Time | 396 ms |
Memory | 18492 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 50 / 50 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | case_000.txt, case_001.txt, case_002.txt, case_003.txt, case_004.txt, case_005.txt, case_006.txt, case_007.txt, case_008.txt, case_009.txt, case_010.txt, case_011.txt, case_012.txt, case_013.txt, case_014.txt, case_015.txt, case_016.txt, case_017.txt, case_018.txt, case_019.txt, case_020.txt, case_021.txt, case_022.txt, case_023.txt, case_024.txt, case_025.txt, case_026.txt, case_027.txt, case_028.txt, case_029.txt, case_030.txt, case_031.txt, case_032.txt, case_033.txt, case_034.txt, case_035.txt, case_036.txt, case_037.txt, case_038.txt, case_039.txt, case_040.txt, case_041.txt, case_042.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
case_000.txt | AC | 374 ms | 18476 KB |
case_001.txt | AC | 390 ms | 18364 KB |
case_002.txt | AC | 382 ms | 18396 KB |
case_003.txt | AC | 384 ms | 18340 KB |
case_004.txt | AC | 370 ms | 18404 KB |
case_005.txt | AC | 372 ms | 18492 KB |
case_006.txt | AC | 372 ms | 18400 KB |
case_007.txt | AC | 374 ms | 18484 KB |
case_008.txt | AC | 373 ms | 18348 KB |
case_009.txt | AC | 372 ms | 18408 KB |
case_010.txt | AC | 379 ms | 18356 KB |
case_011.txt | AC | 379 ms | 18352 KB |
case_012.txt | AC | 383 ms | 18480 KB |
case_013.txt | AC | 379 ms | 18352 KB |
case_014.txt | AC | 396 ms | 18468 KB |
case_015.txt | AC | 389 ms | 18352 KB |
case_016.txt | AC | 370 ms | 18408 KB |
case_017.txt | AC | 394 ms | 18476 KB |
case_018.txt | AC | 383 ms | 18392 KB |
case_019.txt | AC | 376 ms | 18464 KB |
case_020.txt | AC | 389 ms | 18408 KB |
case_021.txt | AC | 374 ms | 18408 KB |
case_022.txt | AC | 389 ms | 18404 KB |
case_023.txt | AC | 373 ms | 18408 KB |
case_024.txt | AC | 394 ms | 18416 KB |
case_025.txt | AC | 376 ms | 18472 KB |
case_026.txt | AC | 396 ms | 18360 KB |
case_027.txt | AC | 374 ms | 18404 KB |
case_028.txt | AC | 394 ms | 18400 KB |
case_029.txt | AC | 385 ms | 18412 KB |
case_030.txt | AC | 380 ms | 18480 KB |
case_031.txt | AC | 375 ms | 18404 KB |
case_032.txt | AC | 395 ms | 18408 KB |
case_033.txt | AC | 375 ms | 18408 KB |
case_034.txt | AC | 396 ms | 18404 KB |
case_035.txt | AC | 376 ms | 18404 KB |
case_036.txt | AC | 383 ms | 18344 KB |
case_037.txt | AC | 376 ms | 18356 KB |
case_038.txt | AC | 386 ms | 18472 KB |
case_039.txt | AC | 376 ms | 18468 KB |
case_040.txt | AC | 390 ms | 18408 KB |
case_041.txt | AC | 385 ms | 18360 KB |
case_042.txt | AC | 388 ms | 18480 KB |