#include <bits/stdc++.h>
using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 1001000;
const int M = 2511;
int a[N];
VI v[N];
void solve() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
set<int> s;
s.insert(-1);
s.insert(1e7);
int ans = 0;
int l = -1;
int r = 1e7;
for (int i = 1; i <= n; i++) {
if (a[i] > a[i - 1] && a[i] <= r) {
s.insert(a[i]);
} else {
// cout << " | ";
s.insert(a[i]);
r = *++s.find(a[i]);
ans++;
}
//cout << a[i] << ' ';
}
cout << ans + 1<< endl;
}
int main() {
ios_base::sync_with_stdio(false);
#ifdef dxz05
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
#endif
int T = 1;
//cin >> T;
while (T--) {
solve();
}
return 0;
}
Compilation message
money.cpp: In function 'void solve()':
money.cpp:51:9: warning: unused variable 'l' [-Wunused-variable]
int l = -1;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
23928 KB |
Output is correct |
2 |
Correct |
27 ms |
23928 KB |
Output is correct |
3 |
Correct |
23 ms |
23928 KB |
Output is correct |
4 |
Correct |
28 ms |
23928 KB |
Output is correct |
5 |
Correct |
27 ms |
23928 KB |
Output is correct |
6 |
Correct |
24 ms |
23920 KB |
Output is correct |
7 |
Incorrect |
23 ms |
23800 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
23928 KB |
Output is correct |
2 |
Correct |
27 ms |
23928 KB |
Output is correct |
3 |
Correct |
23 ms |
23928 KB |
Output is correct |
4 |
Correct |
28 ms |
23928 KB |
Output is correct |
5 |
Correct |
27 ms |
23928 KB |
Output is correct |
6 |
Correct |
24 ms |
23920 KB |
Output is correct |
7 |
Incorrect |
23 ms |
23800 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
23928 KB |
Output is correct |
2 |
Correct |
27 ms |
23928 KB |
Output is correct |
3 |
Correct |
23 ms |
23928 KB |
Output is correct |
4 |
Correct |
28 ms |
23928 KB |
Output is correct |
5 |
Correct |
27 ms |
23928 KB |
Output is correct |
6 |
Correct |
24 ms |
23920 KB |
Output is correct |
7 |
Incorrect |
23 ms |
23800 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
23928 KB |
Output is correct |
2 |
Correct |
27 ms |
23928 KB |
Output is correct |
3 |
Correct |
23 ms |
23928 KB |
Output is correct |
4 |
Correct |
28 ms |
23928 KB |
Output is correct |
5 |
Correct |
27 ms |
23928 KB |
Output is correct |
6 |
Correct |
24 ms |
23920 KB |
Output is correct |
7 |
Incorrect |
23 ms |
23800 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |