답안 #905906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
905906 2024-01-13T07:02:14 Z Muhammad_Aneeq Palembang Bridges (APIO15_bridge) C++17
0 / 100
1 ms 600 KB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/

#include <iostream>
#include <vector>
using namespace std;
void solve()
{
	int k,n;
	cin>>k>>n;
	int ans=0;
	vector<pair<int,int>>d;
	int z=0;
	for (int i=0;i<n;i++)
	{
		char a,b;
		int x,y;
		cin>>a>>x>>b>>y;
		if (a==b)
			ans+=abs(x-y);
		else
		{
			z+=abs(x-y);
			d.push_back({x,y});
		}	
	}
	z/=(d.size());
	for (auto i:d)
		ans+=(abs(i.first-z)+abs(i.second-z))+1;
	cout<<ans<<endl;
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        solve();
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -