Submission #100572

#TimeUsernameProblemLanguageResultExecution timeMemory
100572ExtazyPalembang Bridges (APIO15_bridge)C++17
22 / 100
53 ms3452 KiB
#include <bits/stdc++.h> #define endl '\n' using namespace std; const int N = 200007; int n, k, arr[N], sz; long long ans, offset; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i, x, y; char tmp1[4], tmp2[4]; scanf("%d %d", &k, &n); for(i=1;i<=n;i++) { scanf("%s %d %s %d", tmp1, &x, tmp2, &y); if(tmp1[0]==tmp2[0]) offset += abs(x - y); else { arr[++sz] = x; arr[++sz] = y; ++offset; } } sort(arr + 1, arr + 1 + sz); if(k==1) { ans = offset; for(i=1;i<=sz;i++) { ans += abs(arr[i] - arr[(sz + 1) / 2]); } } else { } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &k, &n);
   ~~~~~^~~~~~~~~~~~~~~~~
bridge.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s %d %s %d", tmp1, &x, tmp2, &y);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...