Submission #844709


Source Code Expand

Copy
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> A(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &A[i]);
		vector<vector<ll>> dp(N + 1, vector<ll>(2, -1));
		dp[0][0] = 0;
		rep(i, N) rep(j, 2) {
			ll x = dp[i][j];
			if(x == -1) continue;
			rep(a, 2) rep(b, 2) {
				if(a + b > A[i]) continue;
				amax(dp[i + 1][b], x + (j + a) / 2 + (A[i] - a - b) / 2);
			}
		}
		ll ans = max(dp[N][0], dp[N][1]);
		printf("%lld\n", ans);
	}
	return 0;
}

Submission Info

Submission Time
Task B - Simplified mahjong
User anta
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1074 Byte
Status AC
Exec Time 45 ms
Memory 6144 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &A[i]);
                      ^

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 45 ms 6144 KB
02.txt AC 45 ms 6144 KB
03.txt AC 45 ms 6144 KB
04.txt AC 41 ms 6144 KB
05.txt AC 41 ms 6144 KB
06.txt AC 41 ms 6144 KB
07.txt AC 43 ms 6144 KB
08.txt AC 43 ms 6144 KB
09.txt AC 45 ms 6144 KB
10.txt AC 45 ms 6144 KB
11.txt AC 34 ms 6144 KB
12.txt AC 44 ms 6144 KB
13.txt AC 44 ms 6144 KB
14.txt AC 44 ms 6144 KB
15.txt AC 34 ms 6144 KB
16.txt AC 43 ms 6144 KB
17.txt AC 45 ms 6144 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