| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 940845 | Maite_Morale | Group Photo (JOI21_ho_t3) | C++14 | 633 ms | 149588 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 5005
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
struct ABI{
vll sum;
ABI(ll n){
sum.assign(n+10,0);
}
void update(ll a,ll b){
if(a<1 || a>=sum.size()){cout<<"anormalona";return;}
for(a;a<sum.size();a+=(a&-a))sum[a]+=b;
}
ll query(ll a){ll r=0;
if(a<1)return r;
a=min(a,(ll)sum.size()-1);
for(a;a>0;a-=(a&-a))r+=sum[a];
return r;
}
ll query(ll a,ll b){
if(a>b)swap(a,b);
return query(b)-query(a-1);
}
} abi1(MAX),abi2(MAX);
ll t,n,a[MAX],mp[MAX],best[MAX],dp[MAX][MAX];
int main(){
fast_in
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];mp[a[i]]=i;
best[i]=oo;
}
for(int i=1;i<=n;i++){
dp[i][i-1]=best[i-1];
for(int j=i;j<=n;j++){
dp[i][j]=dp[i][j-1]+j-1-abi1.query(1,mp[j])-abi2.query(mp[j],n+1);
abi2.update(mp[j],1);
}
for(int j=i;j<=n;j++){
best[j]=min(best[j],dp[i][j]);
abi2.update(mp[j],-1);
}
abi1.update(mp[i],1);
}
cout<<best[n];
return 0;
}컴파일 시 표준 에러 (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... | ||||
