# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1054180 | 2024-08-12T07:20:35 Z | Rojus | Palembang Bridges (APIO15_bridge) | C++14 | 26 ms | 2248 KB |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int k, n; cin >> k >> n; vector<pair<int, int>> v; vector<int> sarasas; set<int> s; long long priedas=0; for(int i=0; i<n; i++) { char cg, cd; int ig, id; cin >> cg >> ig >> cd >> id; if(cg!=cd) { priedas++; v.push_back({ig, id}); sarasas.push_back(ig); sarasas.push_back(id); /*if(s.find(ig)==s.end()) { s.insert(ig); sarasas.push_back(ig); } if(s.find(id)==s.end()) { s.insert(id); sarasas.push_back(id); }*/ } else { priedas+=abs(ig-id); } } sort(sarasas.begin(), sarasas.end()); if(k==1) { int tiltas=sarasas.size()/2; long long sum=priedas; for(int i=0; i<v.size(); i++) { sum+=abs(v[i].first-sarasas[tiltas])+abs(v[i].second-sarasas[tiltas]); } cout << sum; /*long long ats=INT_MAX; for(int i=0; i<sarasas.size(); i++) { long long sum=0; for(int j=0; j<v.size(); j++) { sum+=abs(v[j].first-sarasas[i])+abs(v[j].second-sarasas[i]); } ats=min(ats, sum); } ats+=priedas; cout << ats;*/ } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 484 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 11 ms | 2200 KB | Output is correct |
13 | Correct | 24 ms | 2248 KB | Output is correct |
14 | Correct | 17 ms | 2000 KB | Output is correct |
15 | Correct | 15 ms | 1484 KB | Output is correct |
16 | Correct | 14 ms | 2248 KB | Output is correct |
17 | Correct | 16 ms | 2232 KB | Output is correct |
18 | Correct | 21 ms | 2244 KB | Output is correct |
19 | Correct | 26 ms | 2244 KB | Output is correct |
20 | Correct | 21 ms | 2248 KB | Output is correct |
21 | Correct | 21 ms | 2248 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |