# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
38208 | Talant | Money (IZhO17_money) | C++14 | 0 ms | 9828 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const ll inf = (ll)1e9 + 7;
const int N = (int)1e6 + 7;
int n;
int a[N],t[N],lst = 1;
int ans;
void update (int pos) {
for (; pos <= n; pos += (pos & (-pos)))
t[pos] ++;
}
int get (int pos) {
int res = 0;
for (; pos > 0; pos -= (pos & (-pos)))
res += t[pos];
return res;
}
int main () {
scanf ("%d", &n);
for (int i = 1; i <= n; i ++)
scanf ("%d", &a[i]);
update (a[1]);
for (int i = 2; i <= n; i ++) {
update (a[i]);
if (a[i] == a[i - 1])
continue;
if (a[i] >= a[i - 1]) {
int o = get(a[i]) - get(a[lst] - 1);
if (i - lst + 1 != o) {
ans ++;
lst = i;
}
}
else {
lst = i;
ans ++;
}
}
ans ++;
cout << ans << endl;
}
/**
6
3 6 4 5 1 2
**/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |