답안 #594813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594813 2022-07-13T00:17:21 Z alexz1205 Palembang Bridges (APIO15_bridge) C++14
0 / 100
1 ms 344 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int lint;

int main() {
	int n, k;
	cin >> k >> n;
	lint s = 0, m = 0;
	vector<pair<lint, lint> > nums;
	for (int x = 0; x < n; x ++){
		char a, b;
		int i, j;
		cin >> a >> i >> b >> j;
		if (a == b){
			s += abs(i - j);
		}else {
			nums.push_back(make_pair(i+j, i));
			m += i+j;
		}
	}
	if (k == 1){
		lint i = (m + nums.size()) / (nums.size()*2);
		m = 0;
		for (pair<lint, lint> x: nums){
			lint a = x.second, b = x.first-x.second;
			m += abs(a-i) + abs(b-i);
		}
	}
	m += nums.size();
	cout << m+s << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -