# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56892 |
2018-07-13T05:41:57 Z |
노영훈(#1634) |
None (JOI15_walls) |
C++11 |
|
3000 ms |
17956 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=200010, inf=2e9;
int n, m;
int P[MX];
ll ans=0;
struct wall {
int a, b, idx;
} W[MX];
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>m;
for(int i=1; i<=n; i++){
int a, b; cin>>a>>b;
W[i]={a,b,i};
}
for(int i=1; i<=m; i++) cin>>P[i];
for(int i=1; i<=n; i++){
int len=W[i].b-W[i].a, pos=W[i].a;
ll ans=0;
for(int j=1; j<=m; j++){
if(P[j]<pos || pos+len<P[j]){
int x=abs(pos-P[j]), y=abs(P[j]-(pos+len));
if(x<y) pos=P[j], ans+=x;
else pos=P[j]-len, ans+=y;
}
}
cout<<ans<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
504 KB |
Output is correct |
2 |
Correct |
37 ms |
3144 KB |
Output is correct |
3 |
Correct |
41 ms |
5124 KB |
Output is correct |
4 |
Correct |
34 ms |
7056 KB |
Output is correct |
5 |
Correct |
63 ms |
9048 KB |
Output is correct |
6 |
Correct |
55 ms |
10980 KB |
Output is correct |
7 |
Correct |
48 ms |
12784 KB |
Output is correct |
8 |
Correct |
47 ms |
14760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2758 ms |
15156 KB |
Output is correct |
2 |
Execution timed out |
3025 ms |
17956 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
504 KB |
Output is correct |
2 |
Correct |
37 ms |
3144 KB |
Output is correct |
3 |
Correct |
41 ms |
5124 KB |
Output is correct |
4 |
Correct |
34 ms |
7056 KB |
Output is correct |
5 |
Correct |
63 ms |
9048 KB |
Output is correct |
6 |
Correct |
55 ms |
10980 KB |
Output is correct |
7 |
Correct |
48 ms |
12784 KB |
Output is correct |
8 |
Correct |
47 ms |
14760 KB |
Output is correct |
9 |
Correct |
2758 ms |
15156 KB |
Output is correct |
10 |
Execution timed out |
3025 ms |
17956 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |