# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
329142 | M_W | Mountains (NOI20_mountains) | C++14 | 2095 ms | 10064 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long h[300300];
vector<long long> v;
int main(){
int N;
vector<long long> cnt;
scanf("%d", &N);
for(int i = 0; i < N; i++){
scanf("%lld", &h[i]);
if(i == 0){
v.push_back(h[i]);
cnt.push_back(0);
continue;
}
auto it = upper_bound(v.begin(), v.end(), h[i]);
v.insert(it, h[i]);
cnt.push_back(lower_bound(v.begin(), v.end(), h[i]) - v.begin());
}
v.clear();
long long sum = 0;
for(int i = N - 1; i >= 0; i--){
if(i == 0){
v.push_back(h[i]);
cnt.push_back(0);
continue;
}
auto it = upper_bound(v.begin(), v.end(), h[i]);
v.insert(it, h[i]);
sum += cnt[i] * 1ll * (lower_bound(v.begin(), v.end(), h[i]) - v.begin()) * 1ll;
}
printf("%lld", sum);
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |