제출 #487990

#제출 시각아이디문제언어결과실행 시간메모리
487990ala2Arranging Shoes (IOI19_shoes)C++14
50 / 100
1092 ms4672 KiB
#include "shoes.h" #include <iostream> using namespace std; int b[1000100]; int a[1000100]; void shift(int l,int r) { for(int i=l;i<=r;i++) { b[i]=a[i]; } for(int i=l+1;i<=r;i++) { a[i]=b[i-1]; } a[l]=b[r]; } long long count_swaps(vector<int> s) { int n=s.size(); for(int i=0;i<n;i++) { a[i]=s[i]; } int mn=0; for(int i=0;i<n;i++) { if(a[i]>0) { int e=-1; for(int j=i+1;j<n;j++) { if(a[j]==-a[i]) { e=j; break; } } shift(i,e); mn+=e-i; i++; } if(a[i]<0) { int e=-1; for(int j=i+1;j<n;j++) { if(a[j]==-a[i]) { e=j; break; } } shift(i+1,e); mn+=e-i-1; i++; } } return mn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...