# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
815426 | 2023-08-08T15:01:10 Z | elotelo966 | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 296 KB |
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long count_swaps(std::vector<int> s) { int n=s.size()*2; vector <int> v(n); vector <pair<int,int>> ger; vector <int> cev,cev1; for(int i=0;i<n;i++)v[i]=s[i]; int dizi[n],ind[n]; int tut=0; for(int i=0;i<n;i++){ if(v[i]<0){ dizi[tut]=v[i]; ind[tut]=i; tut+=2; } else{ ger.push_back({v[i],i}); } } sort(ger.begin(),ger.end()); for(int i=0;i<ger.size();i++){ cev.push_back(ger[i].first); cev1.push_back(ger[i].second); //cout<<ger[i].first<<" "<<ger[i].second<<endl; } for(int i=0;i<n;i+=2){ int c=lower_bound(cev.begin(),cev.end(),-dizi[i])-cev.begin(); ind[i+1]=cev1[c]; cev.erase(cev.begin()+c); cev1.erase(cev1.begin()+c); } int ans=0; for(int i=0;i<n;i++){ // cout<<ind[i]<<" "<<abs(ind[i]-i)<<endl; ans+=abs(ind[i]-i); } if((ans/2)%2==0)return ans/2; return ans/2+1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 296 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |