| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 869065 | 12345678 | Palembang Bridges (APIO15_bridge) | C++17 | 30 ms | 1544 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int k, n, b, d;
char a, c;
vector<int> v;
vector<pair<int, int>> p;
long long res, mn=LLONG_MAX;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>k>>n;
if (k==1)
{
for (int i=0; i<n; i++)
{
cin>>a>>b>>c>>d;
if (a==c)
{
res+=abs(b-d);
continue;
}
v.push_back(b);
v.push_back(d);
res++;
}
sort(v.begin(), v.end());
int md=v[v.size()/2];
for (auto x:v) res+=abs(x-md);
cout<<res;
}
else
{
for (int i=0; i<n; i++)
{
cin>>a>>b>>c>>d;
if (a==c)
{
res+=abs(b-d);
continue;
}
p.push_back({min(b, d), max(b, d)});
res++;
}
sort(p.begin(), p.end());
for (int i=0; i<(int)p.size()-1; i++)
{
long long tmp=0;
int ed=i, st=i+1;
vector<int> t1, t2;
for (int j=0; j<=ed; j++) t1.push_back(p[j].first), t1.push_back(p[j].second);
for (int j=st; j<p.size(); j++) t2.push_back(p[j].first), t2.push_back(p[j].second);
int md1=t1[(int)t1.size()/2], md2=t2[(int)t2.size()/2];
for (auto x:t1) tmp+=abs(x-md1);
for (auto x:t2) tmp+=abs(x-md2);
mn=min(mn, tmp);
}
cout<<res+mn;
}
}컴파일 시 표준 에러 (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... | ||||
