Submission #77321

# Submission time Handle Problem Language Result Execution time Memory
77321 2018-09-25T17:51:51 Z 298iq New Home (APIO18_new_home) C++14
5 / 100
4 ms 1564 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 507;
const int INF = 1e9 + 7;

int p[MAXN], c[MAXN], l[MAXN], r[MAXN];
int mn[MAXN];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k, q;
    cin >> n >> k >> q;

    for (int i = 0; i < n; ++i) {
        cin >> p[i] >> c[i] >> l[i] >> r[i];
        --c[i];
    }

    for (int i = 0; i < q; ++i) {
        int np, nt;
        cin >> np >> nt;
        
        for (int j = 0; j < k; ++j) {
            mn[j] = INF;
        }

        for (int j = 0; j < n; ++j) {
            if (l[j] <= nt && nt <= r[j]) {
                mn[c[j]] = min(mn[c[j]], abs(p[j] - np));
            }
        }

        int ans = 0;
        for (int j = 0; j < k; ++j) {
            ans = max(ans, mn[j]);
        }

        if (ans == INF) cout << "-1\n";
        else cout << ans << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 3 ms 676 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 792 KB Output is correct
15 Correct 3 ms 808 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 3 ms 848 KB Output is correct
18 Correct 3 ms 952 KB Output is correct
19 Correct 3 ms 952 KB Output is correct
20 Correct 3 ms 1012 KB Output is correct
21 Correct 3 ms 1036 KB Output is correct
22 Correct 3 ms 1052 KB Output is correct
23 Correct 3 ms 1072 KB Output is correct
24 Correct 3 ms 1092 KB Output is correct
25 Correct 3 ms 1172 KB Output is correct
26 Correct 3 ms 1320 KB Output is correct
27 Correct 3 ms 1320 KB Output is correct
28 Correct 3 ms 1320 KB Output is correct
29 Correct 2 ms 1348 KB Output is correct
30 Correct 2 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 3 ms 676 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 792 KB Output is correct
15 Correct 3 ms 808 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 3 ms 848 KB Output is correct
18 Correct 3 ms 952 KB Output is correct
19 Correct 3 ms 952 KB Output is correct
20 Correct 3 ms 1012 KB Output is correct
21 Correct 3 ms 1036 KB Output is correct
22 Correct 3 ms 1052 KB Output is correct
23 Correct 3 ms 1072 KB Output is correct
24 Correct 3 ms 1092 KB Output is correct
25 Correct 3 ms 1172 KB Output is correct
26 Correct 3 ms 1320 KB Output is correct
27 Correct 3 ms 1320 KB Output is correct
28 Correct 3 ms 1320 KB Output is correct
29 Correct 2 ms 1348 KB Output is correct
30 Correct 2 ms 1364 KB Output is correct
31 Runtime error 3 ms 1448 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1564 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 3 ms 676 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 792 KB Output is correct
15 Correct 3 ms 808 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 3 ms 848 KB Output is correct
18 Correct 3 ms 952 KB Output is correct
19 Correct 3 ms 952 KB Output is correct
20 Correct 3 ms 1012 KB Output is correct
21 Correct 3 ms 1036 KB Output is correct
22 Correct 3 ms 1052 KB Output is correct
23 Correct 3 ms 1072 KB Output is correct
24 Correct 3 ms 1092 KB Output is correct
25 Correct 3 ms 1172 KB Output is correct
26 Correct 3 ms 1320 KB Output is correct
27 Correct 3 ms 1320 KB Output is correct
28 Correct 3 ms 1320 KB Output is correct
29 Correct 2 ms 1348 KB Output is correct
30 Correct 2 ms 1364 KB Output is correct
31 Runtime error 3 ms 1448 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 3 ms 676 KB Output is correct
13 Correct 2 ms 712 KB Output is correct
14 Correct 2 ms 792 KB Output is correct
15 Correct 3 ms 808 KB Output is correct
16 Correct 4 ms 828 KB Output is correct
17 Correct 3 ms 848 KB Output is correct
18 Correct 3 ms 952 KB Output is correct
19 Correct 3 ms 952 KB Output is correct
20 Correct 3 ms 1012 KB Output is correct
21 Correct 3 ms 1036 KB Output is correct
22 Correct 3 ms 1052 KB Output is correct
23 Correct 3 ms 1072 KB Output is correct
24 Correct 3 ms 1092 KB Output is correct
25 Correct 3 ms 1172 KB Output is correct
26 Correct 3 ms 1320 KB Output is correct
27 Correct 3 ms 1320 KB Output is correct
28 Correct 3 ms 1320 KB Output is correct
29 Correct 2 ms 1348 KB Output is correct
30 Correct 2 ms 1364 KB Output is correct
31 Runtime error 3 ms 1448 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -