Submission #844993
Source Code Expand
Copy
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author ilyakor */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskB solver = new TaskB(); solver.solve(1, in, out); out.close(); } static class TaskB { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; ++i) a[i] = in.nextInt(); long res = 0; for (int i = 0; i < n; ++i) { int val = a[i] / 2; res += val; a[i] -= 2 * val; if (a[i] > 0 && i < n - 1 && a[i + 1] > 0) { --a[i]; --a[i + 1]; ++res; } } out.printLine(res); } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object... objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) { writer.print(' '); } writer.print(objects[i]); } } public void printLine(Object... objects) { print(objects); writer.println(); } public void close() { writer.close(); } } static class InputReader { private InputStream stream; private byte[] buffer = new byte[10000]; private int cur; private int count; public InputReader(InputStream stream) { this.stream = stream; } public static boolean isSpace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public int read() { if (count == -1) { throw new InputMismatchException(); } try { if (cur >= count) { cur = 0; count = stream.read(buffer); if (count <= 0) return -1; } } catch (IOException e) { throw new InputMismatchException(); } return buffer[cur++]; } public int readSkipSpace() { int c; do { c = read(); } while (isSpace(c)); return c; } public int nextInt() { int sgn = 1; int c = readSkipSpace(); if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res = res * 10 + c - '0'; c = read(); } while (!isSpace(c)); res *= sgn; return res; } } }
Submission Info
Submission Time | |
---|---|
Task | B - Simplified mahjong |
User | ilyakor |
Language | Java8 (OpenJDK 1.8.0) |
Score | 400 |
Code Size | 3960 Byte |
Status | AC |
Exec Time | 194 ms |
Memory | 9172 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 194 ms | 9044 KB |
02.txt | AC | 194 ms | 9044 KB |
03.txt | AC | 190 ms | 9044 KB |
04.txt | AC | 186 ms | 9168 KB |
05.txt | AC | 186 ms | 9044 KB |
06.txt | AC | 190 ms | 9044 KB |
07.txt | AC | 186 ms | 9044 KB |
08.txt | AC | 186 ms | 9040 KB |
09.txt | AC | 194 ms | 9044 KB |
10.txt | AC | 194 ms | 9044 KB |
11.txt | AC | 183 ms | 8916 KB |
12.txt | AC | 187 ms | 9044 KB |
13.txt | AC | 190 ms | 9044 KB |
14.txt | AC | 190 ms | 9040 KB |
15.txt | AC | 182 ms | 9044 KB |
16.txt | AC | 193 ms | 9172 KB |
17.txt | AC | 194 ms | 9168 KB |
18.txt | AC | 158 ms | 8148 KB |
19.txt | AC | 150 ms | 8148 KB |
20.txt | AC | 154 ms | 8148 KB |
21.txt | AC | 154 ms | 8148 KB |
22.txt | AC | 154 ms | 8144 KB |
s1.txt | AC | 154 ms | 8148 KB |
s2.txt | AC | 154 ms | 8148 KB |