답안 #1054203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054203 2024-08-12T07:34:17 Z idas Palembang Bridges (APIO15_bridge) C++17
22 / 100
23 ms 2652 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;
vector<ll> 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(n==0) {
        cout << ans;
        return 0;
    }
    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;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 11 ms 2520 KB Output is correct
13 Correct 23 ms 2652 KB Output is correct
14 Correct 17 ms 2520 KB Output is correct
15 Correct 13 ms 1500 KB Output is correct
16 Correct 13 ms 2520 KB Output is correct
17 Correct 16 ms 2520 KB Output is correct
18 Correct 19 ms 2520 KB Output is correct
19 Correct 22 ms 2520 KB Output is correct
20 Correct 15 ms 2520 KB Output is correct
21 Correct 20 ms 2520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -