#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define bug cout << "bug" << endl
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pll pair <ll, ll>
#define pii pair <int, int>
#define triple pair <pair <ll, ll> , ll>
#define ull unsigned long long
#define ld long double
#define pinode pair <node*, node*>
const ll INF = 9e18 + 5;
const ll inf = 1e9 + 5;
const ll N = 3e2 + 5;
const ll shift = 2e6;
const ll mod = 1e9 + 7;
const ll M = 10000 + 5;
const ll LOG = 21;
const ll sp = 263;
const ll block = 500;
const double eps = 1e-10;
int n, a[N], ans = 0;
vector <int> cur;
int main(){
speed;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
int st = 1;
cur.pb(0);
cur.pb(1e6 + 1);
while(st <= n){
int nw;
ans++;
for(int i = st; i <= n; i++){
int ok = 0;
for(int j = 1; j < cur.size(); j++){
if(i != st){
if(a[i] < a[i - 1])
break;
}
if(a[st] >= cur[j - 1] && a[i] <= cur[j])
ok++;
}
if(ok >= 2){
while(1){
}
}
if(ok){
nw = i + 1;
continue;
}
break;
}
vector <int> f;
f.pb(0);
for(int j = 1; j < cur.size(); j++){
if(a[st] >= cur[j - 1] && a[nw - 1] <= cur[j]){
for(int i = st; i <= nw - 1; i++){
f.pb(a[i]);
}
for(int i = j; i < cur.size(); i++){
f.pb(cur[i]);
}
break;
}
f.pb(cur[j]);
}
cur = f;
st = nw;
}
cout << ans << endl;
}
/*
%I64d
%I64d
*/
Compilation message
money.cpp: In function 'int main()':
money.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int j = 1; j < cur.size(); j++){
| ~~^~~~~~~~~~~~
money.cpp:67:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int j = 1; j < cur.size(); j++){
| ~~^~~~~~~~~~~~
money.cpp:72:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for(int i = j; i < cur.size(); i++){
| ~~^~~~~~~~~~~~
money.cpp:42:10: warning: 'nw' may be used uninitialized in this function [-Wmaybe-uninitialized]
42 | int nw;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Execution timed out |
1584 ms |
204 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Execution timed out |
1584 ms |
204 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Execution timed out |
1584 ms |
204 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Execution timed out |
1584 ms |
204 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |