# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282893 | 2020-08-25T06:45:13 Z | arnold518 | None (JOI15_walls) | C++14 | 3000 ms | 1536 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5; int N, M; pii A[MAXN+10]; int B[MAXN+10], C[MAXN+10]; int main() { scanf("%d%d", &N, &M); for(int i=1; i<=N; i++) scanf("%d%d", &A[i].first, &A[i].second); for(int i=1; i<=M; i++) scanf("%d", &B[i]); for(int j=1; j<=N; j++) { ll ans=0; int l=A[j].first, r=A[j].second; for(int i=1; i<=M; i++) { if(l<=B[i] && B[i]<=r) continue; else if(B[i]<l) { int t=l-B[i]; ans+=t; l-=t; r-=t; } else if(B[i]>r) { int t=B[i]-r; ans+=t; l+=t; r+=t; } } ans=0; for(int i=M; i>=1; i--) { if(l<=B[i] && B[i]<=r) continue; else if(B[i]<l) { int t=l-B[i]; ans+=t; l-=t; r-=t; } else if(B[i]>r) { int t=B[i]-r; ans+=t; l+=t; r+=t; } } ans+=abs(l-A[j].first); printf("%lld\n", ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 44 ms | 1528 KB | Output is correct |
3 | Correct | 45 ms | 1532 KB | Output is correct |
4 | Correct | 50 ms | 1528 KB | Output is correct |
5 | Correct | 42 ms | 1528 KB | Output is correct |
6 | Correct | 40 ms | 1536 KB | Output is correct |
7 | Correct | 38 ms | 1528 KB | Output is correct |
8 | Correct | 37 ms | 1528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3083 ms | 1152 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 44 ms | 1528 KB | Output is correct |
3 | Correct | 45 ms | 1532 KB | Output is correct |
4 | Correct | 50 ms | 1528 KB | Output is correct |
5 | Correct | 42 ms | 1528 KB | Output is correct |
6 | Correct | 40 ms | 1536 KB | Output is correct |
7 | Correct | 38 ms | 1528 KB | Output is correct |
8 | Correct | 37 ms | 1528 KB | Output is correct |
9 | Execution timed out | 3083 ms | 1152 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |