제출 #797413

#제출 시각아이디문제언어결과실행 시간메모리
797413acatmeowmeowPalembang Bridges (APIO15_bridge)C++11
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 1e5; int k, n, s[N + 5], t[N + 5]; char p[N + 5], q[N + 5]; namespace sub2 { void main(int n, int k, int s[], int t[], char p[], char q[]) { vector<int> arr; int init = 0; for (int i = 1; i <= n; i++) { if (p[i] == q[i]) init += abs(s[i] - t[i]); else arr.push_back(s[i]), arr.push_back(t[i]), init++; } sort(arr.begin(), arr.end()); int ans = 1e18, prefix = 0, suffix = accumulate(arr.begin(), arr.end(), 0ll); for (int i = 0; i < arr.size(); i++) { prefix += arr[i], suffix -= arr[i]; ans = min(ans, (i + 1)*arr[i] - prefix + suffix - ((int)arr.size() - 1 - i)*arr[i]); } cout << init + ans << '\n'; } } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> k >> n; for (int i = 1; i <= n; i++) cin >> p[i] >> s[i] >> q[i] >> t[i]; if (k == 1) sub2::main(n, k, s, t, p, q); else cout << 0 << '\n'; return 0; }

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

bridge.cpp: In function 'void sub2::main(long long int, long long int, long long int*, long long int*, char*, char*)':
bridge.cpp:22:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for (int i = 0; i < arr.size(); i++) {
      |                   ~~^~~~~~~~~~~~
#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...