Submission #845045


Source Code Expand

Copy
#include <bits/stdc++.h>

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = (int)(n); i>=1; --i)
#define fored(i, a, b) for(int i = (int)(b); i >= (int)(a); --i)
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define clr(v) memset(v, 0, sizeof(v))
#define clr1(v) memset(v, 0xFF, sizeof(v))
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef vector<ld> vld;

typedef vector<i64> vi64;

template<class T> bool uax(T&a, const T& b) { if( a < b ) { a = b; return true; } return false; }
template<class T> bool uin(T&a, const T& b) { if( a > b ) { a = b; return true; } return false; }

void solve() {
  int n;
  cin >> n;
  vi a(n);
  forn(i, n) cin >> a[i];
  i64 r = 0;
  forn(i, n) {
    r += a[i] / 2;
    a[i] %= 2;
    if (a[i] && i + 1 < n && a[i + 1]) {
      r += 1;
      a[i] -= 1;
      a[i + 1] -= 1;
    }
  }
  cout << r << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed; cout.precision(15);
  cerr << fixed; cerr.precision(15);
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  solve();
  return 0;
}

Submission Info

Submission Time
Task B - Simplified mahjong
User gchebanov
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1603 Byte
Status AC
Exec Time 27 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 24
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 23 ms 640 KB
02.txt AC 24 ms 640 KB
03.txt AC 24 ms 640 KB
04.txt AC 20 ms 640 KB
05.txt AC 21 ms 640 KB
06.txt AC 23 ms 640 KB
07.txt AC 23 ms 640 KB
08.txt AC 25 ms 640 KB
09.txt AC 27 ms 640 KB
10.txt AC 24 ms 640 KB
11.txt AC 16 ms 640 KB
12.txt AC 24 ms 640 KB
13.txt AC 23 ms 640 KB
14.txt AC 23 ms 640 KB
15.txt AC 16 ms 640 KB
16.txt AC 24 ms 640 KB
17.txt AC 23 ms 640 KB
18.txt AC 4 ms 256 KB
19.txt AC 5 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