답안 #971819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971819 2024-04-29T10:50:55 Z Halym2007 Palembang Bridges (APIO15_bridge) C++17
0 / 100
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz size()
const int N = 1e5 + 5;
ll jogap, a[N], b[N];
int n, k;
char oy[N], of[N];
vector <ll> v;
ll hasapla (ll x, ll y) {
	ll ret = 0;
	for (int i = 1; i <= n; ++i) {
		if (oy[i] == of[i]) {
			ret += abs (a[i] - b[i]);
		}
		else {
			ll gosh = abs (a[i] - x) + abs (x - b[i]) + 1;
			ll gosh1 = 2e18;
			if (k > 1)
			gosh1 = abs (a[i] - y) + abs (y - b[i]) + 1;
			ret += min (gosh, gosh1);
		}
	}
	return ret;
}
 
int main () {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//	freopen ("input.txt", "r", stdin);
	cin >> k >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> oy[i] >> a[i] >> of[i] >> b[i];
	}
	ll goshmaly = 0;
	jogap = 2e18;
	for (int i = 1; i <= n; ++i) {
		if (oy[i] == of[i]) {
			goshmaly += abs (a[i] - b[i]);
		}
		else v.pb (a[i]);v.pb (b[i]);
	}
	sort (v.begin(), v.end());
	jogap = hasapla (v[(int)v.sz / 2 - 1], -1);
	cout << jogap;
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:41:3: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   41 |   else v.pb (a[i]);v.pb (b[i]);
      |   ^~~~
bridge.cpp:41:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   41 |   else v.pb (a[i]);v.pb (b[i]);
      |                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -