# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105712 | Pro_ktmr | 방벽 (JOI15_walls) | C++14 | 3089 ms | 3820 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define MP(a,b) make_pair(a,b)
int N,M;
int A[200000],B[200000];
vector<int> P;
int main(){
cin >> N >> M;
for(int i=0; i<N; i++){
cin >> A[i] >> B[i];
}
int tmp = 0;
for(int i=0; i<M; i++){
int p;
cin >> p;
if(tmp == 0){
if(P.size() > 0){
if(P.back() < p) tmp = 1;
if(P.back() > p) tmp = -1;
}
P.push_back(p);
}
else if(tmp == 1){
if(P.back() <= p) P.back() = p;
else{
tmp = -1;
P.push_back(p);
}
}
else{
if(P.back() >= p) P.back() = p;
else{
tmp = 1;
P.push_back(p);
}
}
}
for(int i=0; i<N; i++){
LL ans = 0;
int a = A[i];
int b = B[i];
for(int j=0; j<P.size(); j++){
if(P[j] > b){
int tmp = P[j] - b;
ans += tmp;
b += tmp;
a += tmp;
}
if(P[j] < a){
int tmp = a - P[j];
ans += tmp;
b -= tmp;
a -= tmp;
}
}
cout << ans << 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... |