# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
670935 | Dan4Life | Palembang Bridges (APIO15_bridge) | C++17 | 2 ms | 368 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
using ll = long long;
using pii = pair<int,int>;
#define all(a) a.begin(),a.end()
#define sz(a) (int)a.size()
const int maxn = (int)1e5+10;
const ll LINF = (ll)1e18;
vector<int> v;
vector<pii> segments;
deque<pii> bef,dur,aft;
int t, n, sum_bef, sum_dur, sum_aft;
int32_t main() {
cin >> t >> n; int tot = 0, sum = 0, ans=LINF;
for(int i = 0; i < n; i++){
char a, c; int b, d;
cin >> a >> b >> c >> d;
if(a==c) tot+=abs(b-d);
else{
if(b>d) swap(b,d); tot++;
segments.pb({b,d});
v.pb(b), v.pb(d);
}
}
v.pb(0), v.pb(1000000000);
sort(all(v));sort(all(segments));
v.erase(unique(all(v)), v.end());
for(auto u : segments) aft.pb(u), sum_aft+=u.fi+u.se;
for(auto u : v){
while(!aft.empty() and aft[0].fi<=u){
dur.pb(aft[0]);
sum_dur+=aft[0].se-aft[0].fi;
sum_aft-=aft[0].fi+aft[0].se;
aft.pop_front();
}
while(!dur.empty() and dur[0].se<u){
bef.pb(dur[0]);
sum_bef+=-dur[0].se-dur[0].fi;
sum_dur-=dur[0].se-dur[0].se;
dur.pop_front();
}
ans = min(ans, (sz(bef)-sz(aft))*2*u+sum_bef+sum_dur+sum_aft);
}
cout << ans+tot;
}
컴파일 시 표준 에러 (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... |