Submission #35265

#TimeUsernameProblemLanguageResultExecution timeMemory
35265cheater2kPalembang Bridges (APIO15_bridge)C++14
22 / 100
56 ms4532 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100005; int k, n; int sz; long long ans; pair<int,int> a[N]; void solve1() { if (n == 0) return; vector<int> z; for (int i = 1; i <= n; ++i) { z.push_back(a[i].first); z.push_back(a[i].second); } sort(z.begin(), z.end()); int med = z[z.size() / 2]; for (int i = 0; i < z.size(); ++i) { ans += abs(med - z[i]); } ans += n; } void solve2() { } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> k >> n; for (int i = 1; i <= n; ++i) { char p, q; int s, t; cin >> p >> s >> q >> t; if (p == q) ans += abs(s - t); else ++sz, a[sz] = make_pair(min(s, t), max(s, t)); } n = sz; if (k == 1) solve1(); else solve2(); printf("%lld\n", ans); }

Compilation message (stderr)

bridge.cpp: In function 'void solve1()':
bridge.cpp:20:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < z.size(); ++i) {
                    ^
#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...