답안 #679163

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679163 2023-01-07T15:26:23 Z hello_there_123 Palembang Bridges (APIO15_bridge) C++17
22 / 100
98 ms 4332 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
/*
1 5
B 0 A 4
B 1 B 3
A 5 B 7
B 2 A 6
B 1 A 7
 
 
 
*/
main(){
	int k,n;
	cin>>k>>n;
	if(k==1){
		int ans = 0;
		vector<int>v;
		for(int i=0;i<n;i++){
			char a,b;
			int c,d;
			cin>>a>>c>>b>>d;
			if(a == b){
				ans+=abs(c-d);
			}
			else{
				v.push_back(c);
				v.push_back(d);
				ans++;
			}
		}
      	int s = v.size();
      	if(s==0){
          cout<<ans;
          return 0;
        }
		sort(v.begin(),v.end());
		int x = v[s/2];
		for(int i=0;i<s;i++){
			ans+=abs(v[i]-x);
		}
		cout<<ans;
	}
}

Compilation message

bridge.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 316 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 340 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 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 2 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 352 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 45 ms 3164 KB Output is correct
13 Correct 98 ms 4220 KB Output is correct
14 Correct 62 ms 3548 KB Output is correct
15 Correct 72 ms 2684 KB Output is correct
16 Correct 84 ms 3640 KB Output is correct
17 Correct 89 ms 4332 KB Output is correct
18 Correct 83 ms 3944 KB Output is correct
19 Correct 98 ms 4236 KB Output is correct
20 Correct 79 ms 3784 KB Output is correct
21 Correct 89 ms 4016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -