Submission #928570


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 D - AtCoDeer and Rock-Paper
User littlesheep
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 1970 Byte
Status
Exec Time 121 ms
Memory 11216 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
× 2
× 25
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, 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, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt
Case Name Status Exec Time Memory
0_000.txt 95 ms 8400 KB
0_001.txt 95 ms 8276 KB
1_002.txt 116 ms 11088 KB
1_003.txt 107 ms 8788 KB
1_004.txt 114 ms 11092 KB
1_005.txt 103 ms 8788 KB
1_006.txt 114 ms 11092 KB
1_007.txt 95 ms 8400 KB
1_008.txt 115 ms 11088 KB
1_009.txt 114 ms 11092 KB
1_010.txt 115 ms 11092 KB
1_011.txt 104 ms 8916 KB
1_012.txt 113 ms 11084 KB
1_013.txt 97 ms 8532 KB
1_014.txt 114 ms 11092 KB
1_015.txt 111 ms 10960 KB
1_016.txt 114 ms 11092 KB
1_017.txt 121 ms 10964 KB
1_018.txt 118 ms 11092 KB
1_019.txt 96 ms 8276 KB
1_020.txt 114 ms 11216 KB
1_021.txt 111 ms 11092 KB
1_022.txt 114 ms 11088 KB
1_023.txt 120 ms 11092 KB
1_024.txt 117 ms 11088 KB