# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
41408 | 2018-02-17T07:35:27 Z | fest | Palembang Bridges (APIO15_bridge) | C++14 | 90 ms | 1640 KB |
// fest #include <bits/stdc++.h> #define pb push_back #define F first #define S second #define y1 dasdasfasfas #define x1 wqdadfasfasfas #define All(c) c.begin(), c.end() #define SZ(A) (int((A).size())) #define umap unordered_map #define FILENAME "" #define __ fflush(stdout) typedef long long ll; typedef long double ld; using namespace std; void FREOPEN() { #ifdef COMP freopen(".in", "r", stdin); freopen("2.out", "w", stdout); #else freopen(FILENAME".in", "r", stdin); freopen(FILENAME".out", "w", stdout); #endif } inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; } const int N = 200500, inf = 1e9 + 1, MOD = (int)1e9 + 7; char CH[N]; const ll INF = 1e18; const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1}; const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1}; vector<int> f, s; ll check(int p) { ll ret = 0; for (auto i : f) ret += abs(i - p); for (auto i : s) ret += abs(i - p); return ret; } int main() { int k, n; cin >> k >> n; ll un = 0; for (int i = 1; i <= n; i++) { char t1, t2; int p1, p2; scanf("\n%c %d %c %d", &t1, &p1, &t2, &p2); if (t2 == 'A') swap(t1, t2), swap(p1, p2); if (t1 == t2) { un += abs(p2 - p1); continue; } f.pb(p1); s.pb(p2); } sort(All(f)), sort(All(s)); int l = 0; int r = inf; while (r - l > 1) { int mid = (l + r) / 2; if (check(mid) > check(mid + 1)) l = mid; else r = mid; } cout << un + SZ(f) + min(check(l), check(r)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 352 KB | Output is correct |
3 | Correct | 2 ms | 404 KB | Output is correct |
4 | Correct | 2 ms | 476 KB | Output is correct |
5 | Correct | 2 ms | 600 KB | Output is correct |
6 | Correct | 2 ms | 600 KB | Output is correct |
7 | Correct | 2 ms | 600 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 2 ms | 600 KB | Output is correct |
10 | Correct | 2 ms | 600 KB | Output is correct |
11 | Correct | 2 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 600 KB | Output is correct |
2 | Correct | 1 ms | 600 KB | Output is correct |
3 | Correct | 2 ms | 600 KB | Output is correct |
4 | Correct | 2 ms | 600 KB | Output is correct |
5 | Correct | 3 ms | 600 KB | Output is correct |
6 | Correct | 2 ms | 600 KB | Output is correct |
7 | Correct | 2 ms | 600 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 2 ms | 600 KB | Output is correct |
10 | Correct | 3 ms | 600 KB | Output is correct |
11 | Correct | 2 ms | 600 KB | Output is correct |
12 | Correct | 48 ms | 1596 KB | Output is correct |
13 | Correct | 79 ms | 1596 KB | Output is correct |
14 | Correct | 61 ms | 1596 KB | Output is correct |
15 | Correct | 47 ms | 1596 KB | Output is correct |
16 | Correct | 54 ms | 1596 KB | Output is correct |
17 | Correct | 62 ms | 1596 KB | Output is correct |
18 | Correct | 65 ms | 1608 KB | Output is correct |
19 | Correct | 78 ms | 1608 KB | Output is correct |
20 | Correct | 90 ms | 1608 KB | Output is correct |
21 | Correct | 72 ms | 1640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1640 KB | Output is correct |
2 | Correct | 2 ms | 1640 KB | Output is correct |
3 | Incorrect | 2 ms | 1640 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1640 KB | Output is correct |
2 | Correct | 2 ms | 1640 KB | Output is correct |
3 | Incorrect | 2 ms | 1640 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1640 KB | Output is correct |
2 | Correct | 2 ms | 1640 KB | Output is correct |
3 | Incorrect | 2 ms | 1640 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |