提出 #26586023


ソースコード 拡げる

/*input
10
426877385 186049196 624834740 836880476 19698398 709113743 436942115 436942115 436942115 503843678

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (int)(lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int a[maxn], b[maxn];

int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	int state = 0;
	REP(i,n){
		if(state == 0 && i != n - 1 && a[i] > a[i + 1]){
			b[i] = 1;
			state = 1;
		}
		if(state == 1 && (i == n - 1 || a[i] < a[i + 1])){
			b[i] = 1;
			state = 0;
		}
	}
	REP(i,n) cout<<b[i]<<" \n"[i==n-1];
	return 0;
}

提出情報

提出日時
問題 A - Gold and Silver
ユーザ iloveUtaha
言語 C++ (GCC 9.2.1)
得点 400
コード長 1905 Byte
結果 AC
実行時間 41 ms
メモリ 5196 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 18
セット名 テストケース
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt
ケース名 結果 実行時間 メモリ
00-sample-001.txt AC 5 ms 3540 KiB
00-sample-002.txt AC 4 ms 3580 KiB
00-sample-003.txt AC 2 ms 3552 KiB
01-001.txt AC 3 ms 3668 KiB
01-002.txt AC 3 ms 3668 KiB
01-003.txt AC 19 ms 4064 KiB
01-004.txt AC 37 ms 4304 KiB
01-005.txt AC 22 ms 4036 KiB
01-006.txt AC 36 ms 4248 KiB
01-007.txt AC 41 ms 5196 KiB
01-008.txt AC 41 ms 5164 KiB
01-009.txt AC 39 ms 5128 KiB
01-010.txt AC 41 ms 5196 KiB
01-011.txt AC 36 ms 4276 KiB
01-012.txt AC 39 ms 4320 KiB
01-013.txt AC 40 ms 4344 KiB
01-014.txt AC 38 ms 4340 KiB
01-015.txt AC 39 ms 4276 KiB