Submission #347713

#TimeUsernameProblemLanguageResultExecution timeMemory
347713bluePalembang Bridges (APIO15_bridge)C++11
22 / 100
116 ms4320 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int K, N;
    cin >> K >> N;

    if(K == 1)
    {
        long long res = 0;
        char c1, c2;
        long long e1, e2;
        vector<long long> A;
        for(int i = 1; i <= N; i++)
        {
            cin >> c1 >> e1 >> c2 >> e2;

            if(c1 == c2) res += abs(e1 - e2);
            else
            {
                A.push_back(e1);
                A.push_back(e2);
                res += 1;
            }
        }
        sort(A.begin(), A.end());
        for(int i = 0; i < A.size(); i++) res += abs(A[i] - A[A.size()/2]);

        cout << res << '\n';
        return 0;
    }
    else
    {
        long long res = 0;
        char c1, c2;
        long long e1, e2;
        vector<long long> A;
        for(int i = 1; i <= N; i++)
        {
            cin >> c1 >> e1 >> c2 >> e2;

            if(c1 == c2) res += abs(e1 - e2);
            else
            {
                A.push_back(e1);
                A.push_back(e2);
                res += 1;
            }
        }


        return 0;
    }
}

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i = 0; i < A.size(); i++) res += abs(A[i] - A[A.size()/2]);
      |                        ~~^~~~~~~~~~
#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...