Submission #12847

# Submission time Handle Problem Language Result Execution time Memory
12847 2015-01-10T02:19:03 Z yongwhan 점 모으기 (KOI13_collect) C++
24 / 24
44 ms 2452 KB
#include <fstream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

int main() {
 ios_base::sync_with_stdio(false); cin.tie(NULL);
 int n,m; cin>>n>>m;
 vector<int> a(m), b(m);
 for (int i=0; i<m; i++) cin>>a[i]>>b[i];
 sort(a.begin(), a.end());
 sort(b.begin(), b.end());

 int x=a[m/2], y=b[m/2], ret=0;
 for (int i=0; i<m; i++) ret+=abs(x-a[i])+abs(y-b[i]);
 cout << ret << endl;
 return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1668 KB Output is correct
2 Correct 0 ms 1668 KB Output is correct
3 Correct 0 ms 1668 KB Output is correct
4 Correct 0 ms 1668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1668 KB Output is correct
2 Correct 0 ms 1668 KB Output is correct
3 Correct 0 ms 1668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1828 KB Output is correct
2 Correct 8 ms 1864 KB Output is correct
3 Correct 4 ms 1828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1904 KB Output is correct
2 Correct 16 ms 1988 KB Output is correct
3 Correct 12 ms 1904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2060 KB Output is correct
2 Correct 16 ms 2140 KB Output is correct
3 Correct 24 ms 2220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2372 KB Output is correct
2 Correct 36 ms 2372 KB Output is correct
3 Correct 28 ms 2372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1812 KB Output is correct
2 Correct 32 ms 2300 KB Output is correct
3 Correct 32 ms 2452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2452 KB Output is correct
2 Correct 40 ms 2452 KB Output is correct
3 Correct 44 ms 2452 KB Output is correct