Submission #1380568
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-10;
int main() {
int N, a[112345];
cin >> N;
REP(i, N) scanf("%d", a + i);
ll ans = 0;
REP(i, N) {
if (a[i] > 2) {
int now;
if (a[i] & 1) now = (a[i] - 1) / 2;
else now = (a[i] - 2) / 2;
ans += now;
a[i] -= now * 2;
}
}
int pos = 0;
while (pos < N) {
if (a[pos] == 2) ans++;
if (a[pos] == 1) {
int cnt = 1;
pos++;
while (pos < N && a[pos] == 2) pos++, cnt++;
if (pos == N) cnt--;
else if (a[pos] != 1) cnt--;
ans += cnt;
}
pos++;
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time
2017-06-25 14:29:27+0900
Task
B - Simplified mahjong
User
tkmst201
Language
C++14 (GCC 5.4.1)
Score
400
Code Size
1163 Byte
Status
AC
Exec Time
14 ms
Memory
640 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:25:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i, N) scanf("%d", a + i);
^
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
13 ms
640 KB
02.txt
AC
13 ms
640 KB
03.txt
AC
13 ms
640 KB
04.txt
AC
12 ms
640 KB
05.txt
AC
12 ms
640 KB
06.txt
AC
12 ms
640 KB
07.txt
AC
13 ms
640 KB
08.txt
AC
13 ms
640 KB
09.txt
AC
13 ms
640 KB
10.txt
AC
13 ms
640 KB
11.txt
AC
9 ms
640 KB
12.txt
AC
14 ms
640 KB
13.txt
AC
13 ms
640 KB
14.txt
AC
13 ms
640 KB
15.txt
AC
9 ms
640 KB
16.txt
AC
13 ms
640 KB
17.txt
AC
13 ms
640 KB
18.txt
AC
1 ms
256 KB
19.txt
AC
1 ms
256 KB
20.txt
AC
1 ms
256 KB
21.txt
AC
1 ms
256 KB
22.txt
AC
1 ms
256 KB
s1.txt
AC
1 ms
256 KB
s2.txt
AC
1 ms
256 KB