Submission #845980
Source Code Expand
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; using ll = long long; #define rep(i, j) for(int i=0; i < (int)(j); i++) #define repeat(i, j, k) for(int i = (j); i < (int)(k); i++) int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; vector<vector<int>> AA; rep(i, N) { vector<int> a; while(i < N and A[i]) { a.push_back(A[i]); i++; } if(a.size()) AA.push_back(a); } ll ans = 0; rep(i, AA.size()) { vector<int> a = AA[i]; vector<int> b = AA[i]; reverse(b.begin(), b.end()); auto f = [](vector<int> &a) -> ll { ll ret = 0; for(int j = 0; j < a.size();) { if(a[j] >= 2) { ret += a[j] / 2; a[j] = a[j] % 2; } else if(a[j] and j + 1 < a.size() and a[j + 1]) { a[j]--; a[j+1]--; ret++; } else j++; } return ret; }; ans += max(f(a), f(b)); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Simplified mahjong |
User | cormoran |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1271 Byte |
Status | AC |
Exec Time | 89 ms |
Memory | 3380 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 | 89 ms | 1776 KB |
02.txt | AC | 80 ms | 1776 KB |
03.txt | AC | 82 ms | 1776 KB |
04.txt | AC | 74 ms | 1976 KB |
05.txt | AC | 72 ms | 1976 KB |
06.txt | AC | 67 ms | 1980 KB |
07.txt | AC | 78 ms | 1596 KB |
08.txt | AC | 79 ms | 1596 KB |
09.txt | AC | 79 ms | 1024 KB |
10.txt | AC | 78 ms | 1024 KB |
11.txt | AC | 33 ms | 640 KB |
12.txt | AC | 86 ms | 1776 KB |
13.txt | AC | 80 ms | 1776 KB |
14.txt | AC | 80 ms | 1776 KB |
15.txt | AC | 56 ms | 3380 KB |
16.txt | AC | 79 ms | 1464 KB |
17.txt | AC | 79 ms | 1272 KB |
18.txt | AC | 4 ms | 256 KB |
19.txt | AC | 4 ms | 256 KB |
20.txt | AC | 6 ms | 256 KB |
21.txt | AC | 4 ms | 256 KB |
22.txt | AC | 4 ms | 256 KB |
s1.txt | AC | 4 ms | 256 KB |
s2.txt | AC | 4 ms | 256 KB |