Submission #1088442

#TimeUsernameProblemLanguageResultExecution timeMemory
1088442SunbaePalembang Bridges (APIO15_bridge)C++17
22 / 100
32 ms3432 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; int a[200000]; signed main(){ int k, n, m = 0; scanf("%d %d", &k, &n); ll tot = 0, s[2] = {0, 0}; for(int i = 0; i<n; ++i){ char c[2]; int p[2]; scanf(" %c %d %c %d", c, p, c+1, p+1); if(c[0] == c[1]) tot += abs(p[0]-p[1]); else {a[m++] = p[0]; a[m++] = p[1];} } sort(a, a+m); for(int j = 0; j<2; ++j) for(int i = 0; i<m; ++i) s[j] += abs(a[i] - a[m/2 - j]); printf("%lld", tot + min(s[0], s[1]) + m/2); }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:6:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  int k, n, m = 0; scanf("%d %d", &k, &n);
      |                   ~~~~~^~~~~~~~~~~~~~~~~
bridge.cpp:9:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   char c[2]; int p[2]; scanf(" %c %d %c %d", c, p, c+1, p+1);
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...