답안 #720776

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720776 2023-04-09T10:02:57 Z mseebacher Palembang Bridges (APIO15_bridge) C++17
22 / 100
41 ms 3564 KB
#include <bits/stdc++.h> 
 
using namespace std;
 
// Idee 1 -> Set mit Wert|Index pair
// Idee 2 -> SegTree damit
 
 
void solve(){
	int k; cin >> k;
	int n; cin >> n;
	
	
	vector<int> diff;
	long long sum = 0;
	for(int i = 0;i<n;i++){
		char t1,t2;
		int c1,c2;
		cin >> t1 >> c1 >> t2 >> c2;
		
		if(t1 == t2){
			sum += abs(c2-c1);
		}else{
			diff.push_back(c1);
			diff.push_back(c2);
		}
	}
	if(diff.size() == 0){
		cout << sum; return;
	} 
	sort(diff.begin(),diff.end());
	sum += (diff.size()/2);
	int mid = diff[diff.size()/2];
	for(int i = 0;i<(int)diff.size();i++){
		sum += abs(diff[i]-mid);
	}
	
	cout << sum << " ";
	
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout << fixed << setprecision(8);
 
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 356 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 244 KB Output is correct
12 Correct 20 ms 1876 KB Output is correct
13 Correct 40 ms 3564 KB Output is correct
14 Correct 28 ms 2624 KB Output is correct
15 Correct 23 ms 2212 KB Output is correct
16 Correct 26 ms 2784 KB Output is correct
17 Correct 27 ms 3528 KB Output is correct
18 Correct 34 ms 3120 KB Output is correct
19 Correct 41 ms 3512 KB Output is correct
20 Correct 36 ms 3096 KB Output is correct
21 Correct 36 ms 3260 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 -
# 결과 실행 시간 메모리 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 -