Submission #1518273
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 ans=0;
int main(){
scanf("%d",&n);
rep(i,1,n){
scanf("%d",a+i);
if(!a[i]) continue;
ans+=a[i]>>1;
if(a[i]&1) a[i]=1;
else a[i]=2,--ans;
}
rep(i,2,n){
int v=qmin(a[i-1],a[i]);
a[i-1]-=v,a[i]-=v;
ans+=v;
}
rep(i,1,n) if(a[i]>=2) ++ans;
printf("%lld\n",ans);
return 0;
}
Submission Info
Submission Time
2017-08-18 10:03:07+0900
Task
B - Simplified mahjong
User
zyding
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
1810 Byte
Status
WA
Exec Time
13 ms
Memory
640 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:58:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:60:18: 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
0 / 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
WA
13 ms
640 KB
02.txt
WA
13 ms
640 KB
03.txt
WA
13 ms
640 KB
04.txt
WA
12 ms
640 KB
05.txt
WA
12 ms
640 KB
06.txt
WA
12 ms
640 KB
07.txt
WA
13 ms
640 KB
08.txt
WA
13 ms
640 KB
09.txt
WA
13 ms
640 KB
10.txt
WA
13 ms
640 KB
11.txt
AC
9 ms
640 KB
12.txt
AC
13 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
WA
13 ms
640 KB
17.txt
WA
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