Submission #1306090
Source Code Expand
import java.util.*; public class Main { public static void main(String args[]) { FastScanner cin = new FastScanner(); String s = cin.next(); StringBuilder p = new StringBuilder(s); int numG = 0, numP = 0, score = 0; for (int i = 0, j = 0; i < s.length(); ++i) { if (p.charAt(i) == 'p') { ++numP; if (numP > numG) { while (s.charAt(j) == p.charAt(j)) ++j; p.setCharAt(j, 'g'); --numP; --score; ++numG; ++j; } } else { if (numP < numG) { ++score; ++numP; p.setCharAt(i, 'p'); } else { ++numG; } } } System.out.println(score); } static class FastScanner { StringTokenizer tokenizer; Scanner scanner; FastScanner() { tokenizer = null; scanner = new Scanner(System.in); } int nextInt() { while (tokenizer == null || !tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(scanner.nextLine()); return Integer.parseInt(tokenizer.nextToken()); } String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(scanner.nextLine()); return tokenizer.nextToken(); } } }
Submission Info
Submission Time | |
---|---|
Task | A - AtCoDeer and Paint Cans |
User | pnnb |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1673 Byte |
Status | WA |
Exec Time | 99 ms |
Memory | 23764 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt |
All | 0_000.txt, 0_001.txt, 1_002.txt, 1_003.txt, 1_004.txt, 1_005.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | WA | 89 ms | 19924 KB |
0_001.txt | WA | 91 ms | 23764 KB |
1_002.txt | WA | 89 ms | 19924 KB |
1_003.txt | AC | 99 ms | 21204 KB |
1_004.txt | WA | 92 ms | 19924 KB |
1_005.txt | WA | 90 ms | 21844 KB |