# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
879625 | alex_2008 | Money (IZhO17_money) | C++14 | 1036 ms | 69784 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <fstream>
#include <random>
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
const int N = 1e6 + 10;
int a[N], dp[N], down[N];
int f[N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
dp[0] = 0;
dp[1] = 1;
down[1] = 1;
for (int i = 2; i <= n; i++) {
down[i] = (a[i] < a[i - 1]) ? i : down[i - 1];
}
set <int> ms;
for (int i = 1; i <= n; i++) {
auto it = ms.upper_bound(a[i]);
if (it == ms.end()) {
f[i] = 10000000;
}
else f[i] = *it;
ms.insert(a[i]);
}
for (int i = 2; i <= n; i++) {
int l = down[i], r = i;
while (l <= r) {
int mid = (l + r) / 2;
bool check = true;
int R = 10000000;
if (f[mid] < a[i]) check = false;
if (check) {
dp[i] = dp[mid - 1] + 1;
r = mid - 1;
}
else l = mid + 1;
}
}
cout << dp[n] << "\n";
}
컴파일 시 표준 에러 (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... |