Submission #928514


Source Code Expand

Copy
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author liymsheep
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();

            int answer = 0;
            for (int i = 0; i < s.length; ++i) {
                if (i % 2 == 0) {
                    if (s[i] == 'p') {
                        --answer;
                    }
                } else {
                    if (s[i] == 'g') {
                        ++answer;
                    }
                }
            }
            out.println(answer);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    throw new UnknownError();
                }
            }
            return tokenizer.nextToken();
        }

    }
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User littlesheep
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 1970 Byte
Status
Exec Time 97 ms
Memory 8404 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 0 / 300 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
Case Name Status Exec Time Memory
0_000.txt 97 ms 8272 KB
0_001.txt 96 ms 8276 KB
0_002.txt 96 ms 8276 KB
1_003.txt 96 ms 8272 KB
1_004.txt 97 ms 8400 KB
1_005.txt 97 ms 8400 KB
1_006.txt 96 ms 8400 KB
1_007.txt 96 ms 8404 KB
1_008.txt 95 ms 8272 KB
1_009.txt 97 ms 8400 KB
1_010.txt 95 ms 8276 KB
1_011.txt 97 ms 8272 KB
1_012.txt 95 ms 8400 KB
1_013.txt 95 ms 8400 KB
1_014.txt 97 ms 8272 KB