Submission #1016934

#TimeUsernameProblemLanguageResultExecution timeMemory
1016934TroySerPalembang Bridges (APIO15_bridge)C++17
8 / 100
2099 ms6128 KiB
#include <bits/stdc++.h> using namespace std; const long long int INF = 1e18; long long int K, N; long long int build1, build2; char zone1, zone2; long long int Dmin = 0; struct Place { char zone; long long int building; }; vector<pair<Place, Place> > people; long long int cost(long long int currK) { long long int currMin = 0; for (int j = 0; j < people.size(); j++) { currMin += abs(people[j].first.building - currK); currMin++; currMin += abs(people[j].second.building - currK); } return currMin; } int main() { cin >> K >> N; for (int i = 0; i < N; i++) { cin >> zone1 >> build1 >> zone2 >> build2; if (zone1 == zone2) { Dmin += abs(build2 - build1); } else { people.push_back(make_pair( (Place){zone1, build1}, (Place){zone2, build2} )); } } int M = people.size(); long long int possibleMin = INF; for (int i = 0; i < M; i++) { possibleMin = min(possibleMin, cost(people[i].first.building)); possibleMin = min(possibleMin, cost(people[i].second.building)); } if (M == 0) possibleMin = 0; cout << possibleMin + Dmin << "\n"; }

Compilation message (stderr)

bridge.cpp: In function 'long long int cost(long long int)':
bridge.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<Place, Place> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int j = 0; j < people.size(); j++) {
      |                     ~~^~~~~~~~~~~~~~~
#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...