Submission #951004

#TimeUsernameProblemLanguageResultExecution timeMemory
951004AmaarsaaPalembang Bridges (APIO15_bridge)C++14
22 / 100
32 ms4364 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long ; int main() { // freopen("hayfeast.in", "r", stdin); // freopen("hayfeast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll t, n, m, ans, s, sum, x, y, r, p, i, j, cnt = 0; cin >> n >> m; ans = 0; char ch1, ch2; vector < ll > v; for (i = 1; i <= m; i ++) { cin >> ch1 >> x >> ch2 >> y; if ( ch1 == ch2) { ans += abs(x - y); } else { v.push_back(x); v.push_back(y); } } sort(v.begin(), v.end()); s = v.size(); s = (s + 1)/2 - 1; for (i = 0; i < v.size(); i ++) { ans = ans + abs(v[s] - v[i]); } cout << ans + v.size()/2<< endl; }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:30:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (i = 0; i < v.size(); i ++) {
      |              ~~^~~~~~~~~~
bridge.cpp:10:5: warning: unused variable 't' [-Wunused-variable]
   10 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j, cnt = 0;
      |     ^
bridge.cpp:10:22: warning: unused variable 'sum' [-Wunused-variable]
   10 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j, cnt = 0;
      |                      ^~~
bridge.cpp:10:33: warning: unused variable 'r' [-Wunused-variable]
   10 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j, cnt = 0;
      |                                 ^
bridge.cpp:10:36: warning: unused variable 'p' [-Wunused-variable]
   10 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j, cnt = 0;
      |                                    ^
bridge.cpp:10:42: warning: unused variable 'j' [-Wunused-variable]
   10 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j, cnt = 0;
      |                                          ^
bridge.cpp:10:45: warning: unused variable 'cnt' [-Wunused-variable]
   10 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j, cnt = 0;
      |                                             ^~~
#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...