# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
978849 | rakhim_ova | 서열 (APIO23_sequence) | C++17 | 2089 ms | 70120 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF=1e13;
int sequence(int n, std::vector<int> a) {
vector<vector<int>> ind(n+1);
for(int i=0; i<n; i++){
ind[a[i]].push_back(i);
}
vector<int> new_a(n);
int mx=1;
for(int i=1; i<=n; i++){
if(i==1){
for(int j=0; j<n; j++){
if(a[j]<i) new_a[j]=-1;
else if(a[j]>i) new_a[j]=1;
else new_a[j]=-1;
}
}
else{
for(int j=0; j<ind[i-1].size(); j++){
new_a[ind[i-1][j]]=-1;
}
for(int j=0; j<ind[i].size(); j++){
new_a[ind[i][j]]=-1;
}
}
map<int, pair<int, int>> mp;
int sm=0;
// cout << i << '\n';
// for(auto x: new_a){
// cout << x << ' ';
// }
// cout << '\n';
for(int j=0; j<n; j++){
sm+=new_a[j];
// cout << sm << ' ';
if(mp.find(sm)!=mp.end()){
mp[sm].second=j;
}
else{
mp[sm].first=j;
mp[sm].second=j;
}
}
// cout << '\n';
vector<int> pref(n);
int cnt=0;
for(int j=0; j<n; j++){
if(a[j]==i){
cnt++;
}
pref[j]=cnt;
}
for(auto x: mp){
// cout << x.first << ' ' << x.second.first << ' ' << x.second.second << '\n';
if(x.second.first==0){
mx=max(mx, pref[x.second.second]);
}
else{
mx=max(mx, pref[x.second.second]-pref[x.second.first-1]);
}
}
// for(auto x: pref){
// cout << x << ' ';
// }
// cout << '\n';
}
return mx;
}
컴파일 시 표준 에러 (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... |