forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path188.cpp
More file actions
42 lines (38 loc) · 775 Bytes
/
188.cpp
File metadata and controls
42 lines (38 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//ac
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
int n, t;
int l[20], v[20];
int num[20];
int main() {
memset(num, 0, sizeof(num));
scanf("%d %d", &n, &t);
for (int i = 0; i < n; ++i) scanf("%d", &l[i]);
for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (v[i] * v[j] > 0) continue;
int dis;
if (v[i] < 0)
dis = l[i] - l[j];
else
dis = l[j] - l[i];
if (dis < 0) dis += 1000;
int total = (abs(v[i]) + abs(v[j])) * t;
if (total >= dis) {
num[i]++;
num[i] += (total - dis) / 1000;
}
}
}
for (int i = 0; i < n; ++i) {
if (i) printf(" ");
printf("%d", num[i]);
}
printf("\n");
return 0;
}