제출 #56556

#제출 시각아이디문제언어결과실행 시간메모리
56556leejseoPalembang Bridges (APIO15_bridge)C++98
0 / 100
3 ms992 KiB
#include <bits/stdc++.h> using namespace std; int K, N; long long ans; vector<int> L; int main(void){ int u, v; char x, y; scanf("%d%d", &K, &N); for(int i=0; i<N; i++){ scanf("%c %d %c %d\n", &x, &u, &y, &v); if (x == y) ans += abs(u-v); else{ L.push_back(u); L.push_back(v); } } sort(L.begin(), L.end()); int M = L.size(); if (M == 0){ printf("%d\n", ans); return 0; } long long mid = L[M/2]; for (int i=0; i<M; i++) ans += abs(L[i] - mid); printf("%d\n", ans); return 0; }

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

bridge.cpp: In function 'int main()':
bridge.cpp:23:21: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   printf("%d\n", ans);
                     ^
bridge.cpp:28:20: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  printf("%d\n", ans);
                    ^
bridge.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &K, &N);
  ~~~~~^~~~~~~~~~~~~~~~
bridge.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%c %d %c %d\n", &x, &u, &y, &v);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...