| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1028721 | vjudge1 | Palembang Bridges (APIO15_bridge) | C++17 | 87 ms | 6484 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, sm, cnt;
vector<pair<ll, ll>> vec;
vector<ll> l, r, both;
int main(){
cin >> k >> n;
for (ll i = 0; i < n; i ++){
char p, q;
ll s, t;
cin >> p >> s >> q >> t;
if (s > t) swap(s, t);
if (p == q){
cnt++;
sm += t - s;
}
else{
vec.push_back({s, t});
l.push_back(s);
r.push_back(t);
both.push_back(s);
both.push_back(t);
}
}
sort(vec.begin(), vec.end());
sort(l.begin(), l.end());
sort(r.begin(), r.end());
sort(both.begin(), both.end());
ll ans = 1e18;
if (k == 1){
ll prev = 0;
ll after = 0;
for (ll i = 1; i < both.size(); i ++)
after += both[i] - both[0];
ans = min(ans, sm + after + n - cnt);
for (ll i = 1; i < both.size(); i ++){
after -= (both[i] - both[i - 1]) * (both.size() - i);
prev += (both[i] - both[i - 1]) * i;
ans = min(ans, sm + prev + after + n - cnt);
}
cout << ans << endl;
}
}컴파일 시 표준 에러 (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... | ||||
