제출 #959450

#제출 시각아이디문제언어결과실행 시간메모리
959450NemanjaSo2005Arranging Shoes (IOI19_shoes)C++17
0 / 100
0 ms348 KiB
#include "shoes.h" #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=2e5+5; ll N,niz[maxn],par[maxn]; ll res=0; map<int,queue<int>> mapa; ll count_swaps(vector<int> s) { N=s.size(); for(int i=0;i<N;i++) niz[i+1]=s[i]; for(int i=1;i<=N;i++){ int sup=-niz[i]; if(mapa[sup].size()!=0){ int x=mapa[sup].front(); mapa[sup].pop(); par[x]=i; par[i]=x; continue; } mapa[niz[i]].push(i); } for(int i=1;i<=N;i++){ if(niz[i]==0) continue; if(niz[i]>0) /// Zamena leva-desna na kraju res++; for(int j=i+1;j<par[i];j++) if(niz[j]!=0) res++; } return res; }
#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...