Submission #845059
Source Code Expand
Copy
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
using namespace std;
using ll=long long;
ll a[100010];
int main(void){
int n;
cin >> n;
rep(i,n) cin >> a[i];
ll ans=0LL;
if(n==1){
cout << a[0]/2LL << endl;
return 0;
}
rep(i,1,n){
ll sum=(a[i]+a[i-1]);
ll cnt=sum/2LL;
ans+=cnt;
if(sum%2==1){
if(a[i]==0)
a[i-1]=1LL;
else
a[i]=1LL;
}else
a[i-1]=a[i]=0LL;
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Simplified mahjong |
User |
Hec |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1259 Byte |
Status |
AC |
Exec Time |
128 ms |
Memory |
1024 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 |
117 ms |
1024 KB |
02.txt |
AC |
116 ms |
1024 KB |
03.txt |
AC |
107 ms |
1024 KB |
04.txt |
AC |
77 ms |
1024 KB |
05.txt |
AC |
80 ms |
1024 KB |
06.txt |
AC |
76 ms |
1024 KB |
07.txt |
AC |
101 ms |
1024 KB |
08.txt |
AC |
100 ms |
1024 KB |
09.txt |
AC |
118 ms |
1024 KB |
10.txt |
AC |
113 ms |
1024 KB |
11.txt |
AC |
34 ms |
1024 KB |
12.txt |
AC |
128 ms |
1024 KB |
13.txt |
AC |
119 ms |
1024 KB |
14.txt |
AC |
115 ms |
1024 KB |
15.txt |
AC |
34 ms |
1024 KB |
16.txt |
AC |
118 ms |
1024 KB |
17.txt |
AC |
118 ms |
1024 KB |
18.txt |
AC |
4 ms |
256 KB |
19.txt |
AC |
4 ms |
256 KB |
20.txt |
AC |
4 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 |