# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
640663 | devariaota | Palembang Bridges (APIO15_bridge) | C++17 | 2068 ms | 13592 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long ll;
// const ll mod = 1e9 + 7;
const ll MAXN = 1e6 + 5;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define endl '\n'
#define gl ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
gl;
ll k, n;
cin >> k >> n;
ll sum = 0;
vll v;
set<ll> st;
for (int i = 0; i < n; i++)
{
char a, b;
ll x, y;
cin >> a >> x >> b >> y;
if (a == b)
sum += abs(x - y);
else
{
sum++;
v.pb(x);
v.pb(y);
st.insert(x);
st.insert(y);
}
}
sort(v.begin(), v.end());
ll ans = 1e18;
for (ll i : st)
{
ll cur = 0;
for (int j = 0; j < v.size(); j++)
{
cur += abs(i - v[j]);
}
ans = min(ans, cur);
}
if (ans == 1e18)
ans = 0;
cout << ans + sum << endl;
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... |