Submission #672328

#TimeUsernameProblemLanguageResultExecution timeMemory
672328hariaakas646Best Place (NOI17_bestplace)C++14
100 / 100
41 ms3820 KiB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int median(vector<int> vec) {
    sort(vec.begin(), vec.end());
    int s = vec.size();
    if(s % 2 == 0) {
        return (vec[s/2] + vec[s/2 - 1]) / 2;
    }
    else {
        return vec[s/2];
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> X_vec(n), Y_vec(n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d", &X_vec[i], &Y_vec[i]);
    }
    printf("%d %d", median(X_vec), median(Y_vec));

    return 0;
}

Compilation message (stderr)

bestplace.cpp: In function 'int main()':
bestplace.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bestplace.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d %d", &X_vec[i], &Y_vec[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...
#Verdict Execution timeMemoryGrader output
Fetching results...