# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
56558 | 2018-07-11T17:14:16 Z | leejseo | Palembang Bridges (APIO15_bridge) | C++ | 85 ms | 1768 KB |
#include <bits/stdc++.h> using namespace std; int K, N; void solve1(){ long long ans = 0; vector<int> L; int u, v; char x, y; for(int i=0; i<N; i++){ scanf("%c %d %c %d\n", &x, &u, &y, &v); if (x == y) ans += abs(u-v); else{ L.push_back(u); L.push_back(v); } } sort(L.begin(), L.end()); int M = L.size(); if (M == 0){ printf("%lld\n", ans); return; } long long mid = L[M/2]; for (int i=0; i<M; i++) ans += abs(L[i] - mid); ans += M/2; printf("%lld\n", ans); L.clear(); return; } int main(void){ scanf("%d%d\n", &K, &N); if (K == 1) solve1(); else printf("-1"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 428 KB | Output is correct |
4 | Correct | 2 ms | 556 KB | Output is correct |
5 | Correct | 3 ms | 556 KB | Output is correct |
6 | Correct | 3 ms | 556 KB | Output is correct |
7 | Correct | 3 ms | 608 KB | Output is correct |
8 | Correct | 3 ms | 608 KB | Output is correct |
9 | Correct | 3 ms | 696 KB | Output is correct |
10 | Correct | 2 ms | 696 KB | Output is correct |
11 | Correct | 2 ms | 696 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 696 KB | Output is correct |
2 | Correct | 2 ms | 696 KB | Output is correct |
3 | Correct | 3 ms | 696 KB | Output is correct |
4 | Correct | 4 ms | 696 KB | Output is correct |
5 | Correct | 3 ms | 696 KB | Output is correct |
6 | Correct | 2 ms | 696 KB | Output is correct |
7 | Correct | 2 ms | 696 KB | Output is correct |
8 | Correct | 2 ms | 696 KB | Output is correct |
9 | Correct | 2 ms | 696 KB | Output is correct |
10 | Correct | 3 ms | 696 KB | Output is correct |
11 | Correct | 2 ms | 696 KB | Output is correct |
12 | Correct | 31 ms | 1680 KB | Output is correct |
13 | Correct | 68 ms | 1764 KB | Output is correct |
14 | Correct | 44 ms | 1764 KB | Output is correct |
15 | Correct | 42 ms | 1764 KB | Output is correct |
16 | Correct | 44 ms | 1764 KB | Output is correct |
17 | Correct | 57 ms | 1764 KB | Output is correct |
18 | Correct | 55 ms | 1764 KB | Output is correct |
19 | Correct | 68 ms | 1768 KB | Output is correct |
20 | Correct | 50 ms | 1768 KB | Output is correct |
21 | Correct | 85 ms | 1768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |