Submission #348034

# Submission time Handle Problem Language Result Execution time Memory
348034 2021-01-14T04:42:24 Z ThinGarfield Palembang Bridges (APIO15_bridge) C++11
22 / 100
49 ms 4328 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define F first
#define S second
using pip = pair<int, pii>;  // (s+t)/2, s, t

constexpr ll sc = 4;
constexpr ll maxx = 2e9 + 18;
constexpr int maxn = 1e5 + 18;
ll cost;
int n, k;
vector<ll> endpts;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> k >> n;
    for (int i = 0; i < n; i++) {
        char s1, t1;
        int s, t;
        cin >> s1 >> s >> t1 >> t;
        if (s1 == t1) {
            cost += sc * abs(t - s);
            // cout << '+' << sc * abs(t - s) << '\n';
        } else {
            endpts.push_back(sc * s);
            endpts.push_back(sc * t);
        }
    }
    sort(endpts.begin(), endpts.end());
    if (k == 1) {
        int eps = endpts.size() / 2;
        if (eps != 0) {
            int bloc = (endpts[eps] + endpts[eps - 1]) / 2;
            for (int x : endpts) {
                cost += abs(bloc - x);
                // cout << '+' << abs(bloc - x) << '\n';
            }
            cost += (eps * sc);
            // cout << '+' << eps * sc << '\n';
        }
        cout << cost / sc << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 24 ms 3304 KB Output is correct
13 Correct 47 ms 4328 KB Output is correct
14 Correct 36 ms 3688 KB Output is correct
15 Correct 27 ms 2792 KB Output is correct
16 Correct 33 ms 3816 KB Output is correct
17 Correct 35 ms 4324 KB Output is correct
18 Correct 40 ms 4072 KB Output is correct
19 Correct 49 ms 4328 KB Output is correct
20 Correct 33 ms 3944 KB Output is correct
21 Correct 43 ms 4072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -