# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
72256 | | 호우주의보 (#118) | Box Run (FXCUP3_box) | C++17 | | 971 ms | 32992 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,M;
vector<tuple<int,int> >V;
set<int> S;
int lenn[500005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin>>N;
fill (lenn,lenn+N+1,N+1);
V.push_back(make_tuple(-1000000001,0));
for(int i=1;i<=N;i++)
{
int T;
cin>>T;
V.push_back(make_tuple(-T,i));
}
sort(V.begin(),V.end());
for(int i=0;i<V.size();)
{
for(int j=i;get<0>(V[i])==get<0>(V[j]);j++)
S.insert(get<1>(V[j]));
for(int j=i;get<0>(V[i])==get<0>(V[j]);j++)
{
auto K=S.lower_bound(get<1>(V[j]));
if(K!=S.begin())
{
int&R=lenn[get<1>(V[j])-*(--K)-1];
R=min(R,get<1>(V[j]));
}
}
for(i++;get<0>(V[i])==get<0>(V[i-1]);i++);
}
for(int i=N-1;i;i--)lenn[i]=min(lenn[i],lenn[i+1]);
for(int i=1;i<=N;i++)
{
if(lenn[i]==N+1)printf("-1 ");
else printf("%d ",lenn[i]-i);
}
}
Compilation message (stderr)
box.cpp: In function 'int main()':
box.cpp:23:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();)
~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |