# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105712 | 2019-04-14T04:20:06 Z | Pro_ktmr | 방벽 (JOI15_walls) | C++14 | 3000 ms | 3820 KB |
#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; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 512 KB | Output is correct |
2 | Correct | 98 ms | 3460 KB | Output is correct |
3 | Correct | 114 ms | 3196 KB | Output is correct |
4 | Correct | 107 ms | 3180 KB | Output is correct |
5 | Correct | 102 ms | 3200 KB | Output is correct |
6 | Correct | 101 ms | 3180 KB | Output is correct |
7 | Correct | 94 ms | 3052 KB | Output is correct |
8 | Correct | 121 ms | 2424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1034 ms | 1380 KB | Output is correct |
2 | Execution timed out | 3089 ms | 3820 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 512 KB | Output is correct |
2 | Correct | 98 ms | 3460 KB | Output is correct |
3 | Correct | 114 ms | 3196 KB | Output is correct |
4 | Correct | 107 ms | 3180 KB | Output is correct |
5 | Correct | 102 ms | 3200 KB | Output is correct |
6 | Correct | 101 ms | 3180 KB | Output is correct |
7 | Correct | 94 ms | 3052 KB | Output is correct |
8 | Correct | 121 ms | 2424 KB | Output is correct |
9 | Correct | 1034 ms | 1380 KB | Output is correct |
10 | Execution timed out | 3089 ms | 3820 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |