Skip to content

Instantly share code, notes, and snippets.

@mi6112ogit
Created December 11, 2017 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mi6112ogit/60247aaaa2a52c1e59dfdb998382e5aa to your computer and use it in GitHub Desktop.
Save mi6112ogit/60247aaaa2a52c1e59dfdb998382e5aa to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18
#define fi first
#define se second
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
int n, a[103];
bool solve(int m, int cnt) {
if(cnt == n + 2) return true;
FOR(i, 1, m + 1) {
if(a[cnt + i] != 1) return solve(m, cnt + i);
}
return false;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
FOR(i, 2, n + 2) cin >> a[i];
FOR(i, 1, n + 2) {
bool flag = solve(i, 1);
if(flag) {
cout << i << endl;
break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment