이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define ssize(x) int(x.size())
#define pn printf("\n")
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int inf = 2e09; ll infll = 2e18;
int base = 1;
struct seg{
vector<int> t;
void init(int n){
while(base < n) base <<= 1;
t.resize(base<<1);
}
void update(int i, int val){
for(i += base-1, t[i] = val, i >>= 1; i; i >>= 1) t[i] = max(t[i<<1], t[i<<1|1]);
}
int query(int i, int s, int e, int x, int y){
if(x <= s && e <= y) return t[i];
int mid = (s+e)>>1, ret = 0;
if(x <= mid) ret = max(ret, query(i<<1, s, mid, x, y));
if(mid < y) ret = max(ret, query(i<<1|1, mid+1, e, x, y));
return ret;
}
int qr(int x, int y){
if(x <= y) return query(1, 1, base, max(1, x), min(base, y));
return 0;
}
};
void answer(){
int n, d; scanf("%d%d", &n, &d);
set<int> sc;
vector<int> t(n+1);
for(int i = 1; i <= n; ++i) scanf("%d", &t[i]), sc.emplace(t[i]);
unordered_map<int, int> mp; int it = 0;
for(int u : sc) mp[u] = ++it;
for(int i = 1; i <= n; ++i) t[i] = mp[t[i]];
int mx = 0, result = 0;
vector<int> st;
for(int i = n; i; --i){
while(!st.empty() && t[st.back()] <= t[i]) st.pop_back();
st.emplace_back(i);
result = max(result, ssize(st));
}
printf("%d\n", result);
}
int main(){
int T = 1;
for(++T; --T; ) answer();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'void answer()':
Main.cpp:41:7: warning: unused variable 'mx' [-Wunused-variable]
41 | int mx = 0, result = 0;
| ^~
Main.cpp:34:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | int n, d; scanf("%d%d", &n, &d);
| ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:37:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | for(int i = 1; i <= n; ++i) scanf("%d", &t[i]), sc.emplace(t[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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |