Submission #1054193

# Submission time Handle Problem Language Result Execution time Memory
1054193 2024-08-12T07:28:04 Z idas Palembang Bridges (APIO15_bridge) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define pb push_back
#define s second
#define f first

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int N=1e5+10;
int k, n;
ll ans;
vi a;

int main() {
    FAST_IO;
    cin >> k >> n;
    FOR(i, 0, n) {
        char c1, c2; int x1, x2;
        cin >> c1 >> x1 >> c2 >> x2;
        if(c1==c2) {
            ans+=abs(x1-x2);
        }
        else {
            a.pb(x1);
            a.pb(x2);
        }
    }
    sort(a.begin(), a.end());
    n=a.size();
    ans+=n/2;
    if(k==1) {
        ll sm=0, cn=0;
        FOR(i, 0, n/2) sm+=a[i], cn++;
        ans+=a[n/2]*cn-sm;

        sm=0; cn=0;
        FOR(i, n/2+1, n) sm+=a[i], cn++;
        ans+=sm-a[n/2]*cn;
        cout << ans;
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -