Submission #1518284


Source Code Expand

#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;

int a[N],n;
ll f[N][2];

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a+i);
	f[0][1]=-linf;
	rep(i,1,n){
		f[i][0]=f[i-1][0]+(a[i]>>1);
		if(a[i]>1) getmax(f[i][0],f[i-1][1]+((a[i]-1)>>1));
		if(!a[i]){
			f[i][1]=-linf;
			continue;
		}
		--a[i];
		f[i][1]=f[i-1][0]+(a[i]>>1)+1;
		if(a[i]>1) getmax(f[i][1],f[i-1][1]+((a[i]-1)>>1)+1); 
	}
	printf("%lld\n",f[n][0]); 
	return 0;
}

Submission Info

Submission Time
Task B - Simplified mahjong
User zyding
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1893 Byte
Status AC
Exec Time 14 ms
Memory 2176 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:59:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:60:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep(i,1,n) 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 13 ms 2176 KB
02.txt AC 13 ms 2176 KB
03.txt AC 14 ms 2176 KB
04.txt AC 12 ms 2176 KB
05.txt AC 12 ms 2176 KB
06.txt AC 12 ms 2176 KB
07.txt AC 13 ms 2176 KB
08.txt AC 13 ms 2176 KB
09.txt AC 13 ms 2176 KB
10.txt AC 13 ms 2176 KB
11.txt AC 9 ms 2176 KB
12.txt AC 14 ms 2176 KB
13.txt AC 13 ms 2176 KB
14.txt AC 13 ms 2176 KB
15.txt AC 9 ms 2176 KB
16.txt AC 14 ms 2176 KB
17.txt AC 13 ms 2176 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