Submission #15860

#TimeUsernameProblemLanguageResultExecution timeMemory
15860myungwooPalembang Bridges (APIO15_bridge)C++14
0 / 100
0 ms2020 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(v) ((int)(v).size()) #define all(v) (v).begin(), (v).end() typedef long long lld; int K, N; int main() { scanf("%d%d", &K, &N); vector <int> arr; lld ans = 0; for (int i=1;i<=N;i++){ char p, q; int a, b; scanf(" %c%d %c%d", &p, &a, &q, &b); if (p == q){ ans += abs(a-b); continue; } ans++; arr.pb(a); arr.pb(b); } sort(all(arr)); int x = arr[sz(arr)/2]; for (int t: arr) ans += abs(t - x); printf("%lld\n", ans); }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:13:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &K, &N);
                       ^
bridge.cpp:18:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c%d %c%d", &p, &a, &q, &b);
                                      ^
#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...