답안 #107003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107003 2019-04-21T12:37:44 Z someone_aa Palembang Bridges (APIO15_bridge) C++17
22 / 100
203 ms 7896 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll s[maxn], f[maxn], n, k;
char szone[maxn], fzone[maxn];

int main() {
    cin>>k>>n;
    ll result = 0LL;

    vector<ll>v;
    vector<pair<ll,ll> > vv;
    for(int i=1;i<=n;i++) {
        cin>>szone[i]>>s[i];
        cin>>fzone[i]>>f[i];
        if(szone[i] == fzone[i]) result += abs(f[i] - s[i]);
        if(szone[i] != fzone[i]) {
            v.pb(s[i]);
            v.pb(f[i]);
        }
        vv.pb(mp(min(s[i], f[i]), max(s[i], f[i])));
    }

    if(v.size() == 0) {
        cout<<result;
        return 0;
    }

    if(k == 1) {
        ll mintemp = LLONG_MAX;
        sort(v.begin(), v.end());

        // 0 1 2 3

        int half = v[0];
        if(v.size() > 1)
            half = v[v.size()/2-1];
        else half = v.back();
        for(int d=half-1;d<=half+1;d++) {
            ll temp = 0LL;
            for(int i=1;i<=n;i++) {
                if(szone[i] != fzone[i]) {
                    temp += abs(f[i] - d) + abs(s[i] - d) + 1;
                }
            }
            //cout<<d<<": "<<temp<<"\n";
            mintemp = min(mintemp, temp);
        }

        result += mintemp;
        cout<<result<<"\n";
        return 0;
    }
    else if(k == 2) {
        for(int i:v) {

        }
    }

    return 0;
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:58:17: warning: unused variable 'i' [-Wunused-variable]
         for(int i:v) {
                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 95 ms 6072 KB Output is correct
13 Correct 203 ms 7788 KB Output is correct
14 Correct 86 ms 6020 KB Output is correct
15 Correct 73 ms 4708 KB Output is correct
16 Correct 154 ms 7128 KB Output is correct
17 Correct 131 ms 7896 KB Output is correct
18 Correct 129 ms 7420 KB Output is correct
19 Correct 144 ms 7764 KB Output is correct
20 Correct 107 ms 7256 KB Output is correct
21 Correct 134 ms 7436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -