이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, a[1000000], h = 0, c = -1, t = 0, l = 0;
vector<pair<int, int> > pv, is;
int main(){
cin >> n;
for(int i = 0; i < n; i++) cin >> a[i];
if(n > 1){
if(a[0] > a[1]) pv.push_back(make_pair(a[0], 1));
if(a[n-1] > a[n-2]) pv.push_back(make_pair(a[n-1], 1));
}
for(int i = 1; i < n-1; i++){
if(a[i-1] > a[i]){
while(a[i] == a[i+1]) i++;
if(a[i] < a[i+1]) pv.push_back(make_pair(a[i], -1));
} else if(a[i-1] < a[i]){
while(a[i] == a[i+1]) i++;
if(a[i] > a[i+1]) pv.push_back(make_pair(a[i], 1));
}
}
sort(pv.begin(), pv.end());
reverse(pv.begin(), pv.end());
for(int i = 0; i < pv.size(); i++){
if(pv[i].first == c) t += pv[i].second;
else {
if(c != -1) is.push_back(make_pair(c, t));
c = pv[i].first;
t = pv[i].second;
}
}
for(int i = 0; i < is.size(); i++){
l += is[i].second;
h = max(h, l);
}
cout << h;
}
컴파일 시 표준 에러 (stderr) 메시지
gw.cpp: In function 'int main()':
gw.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < pv.size(); i++){
~~^~~~~~~~~~~
gw.cpp:32:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < is.size(); i++){
~~^~~~~~~~~~~
# | 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... |