제출 #43390

#제출 시각아이디문제언어결과실행 시간메모리
43390top34051Palembang Bridges (APIO15_bridge)C++14
22 / 100
81 ms2284 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn = 2e5 + 5; int n,m,k,sz; int a[maxn], b[maxn]; int pos[maxn]; ll solve1() { ll res = 0; sz = 0; for(int i=1;i<=n;i++) pos[sz++] = a[i], pos[sz++] = b[i]; sort(&pos[0],&pos[sz]); int opt = pos[sz/2]; for(int i=0;i<sz;i++) res += abs(opt-pos[i]); return res; } int main() { long long extra = 0; scanf("%d%d",&k,&n); for(int i=1;i<=n;i++) { int x, y; char t1, t2; scanf(" %c%d %c%d",&t1,&x,&t2,&y); if(t1==t2) extra += abs(x-y); else { m++; a[m] = x; b[m] = y; extra++; } } n = m; printf("%lld",extra + solve1()); }

컴파일 시 표준 에러 (stderr) 메시지

bridge.cpp: In function 'int main()':
bridge.cpp:19:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&k,&n);
                        ^
bridge.cpp:22:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c%d %c%d",&t1,&x,&t2,&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...