제출 #594738

#제출 시각아이디문제언어결과실행 시간메모리
594738alexz1205Palembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms340 KiB
#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; lint 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){ 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...