이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18+7;
ll plan_roller_coaster(vector<int>S, vector<int>T) {
int n=S.size();
vector<pair<ll,ll>>V;
rep(i, n) {
V.pb({S[i], 1});
V.pb({T[i], -1});
}
sort(all(V));
ll lst=V[0].st, sum=-1, ans=0;
int czy=0;
for(auto i : V) {
ans+=(i.st-lst)*max(sum, 0ll);
if(i.st!=lst) {
if(sum!=0) {
if(czy==2) {
return 1;
}
czy=1;
} else if(czy==1) czy=2;
}
sum+=i.nd;
lst=i.st;
}
return ans;
}
# | 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... |