Submission #594735

# Submission time Handle Problem Language Result Execution time Memory
594735 2022-07-12T22:16:30 Z alexz1205 Palembang Bridges (APIO15_bridge) C++14
0 / 100
1 ms 340 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;
			m += j;
		}
	}
	if (k == 1){
		int i = (m + nums.size()) / (nums.size()*2);
		m = 0;
		for (pair<lint, lint> x: nums){
			int a = x.second, b = x.first-x.second;
			m += abs(a-i) + abs(b-i);
		}
	}
	m += nums.size();
	cout << m+s << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 304 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -