結果
| 問題 |
No.2315 Flying Camera
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-26 21:30:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 762 bytes |
| コンパイル時間 | 2,993 ms |
| コンパイル使用メモリ | 160,644 KB |
| 最終ジャッジ日時 | 2025-02-13 05:52:51 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
int main(){
int n;
cin >> n;
vector<int> x(n);
vector<int> y(n);
rep(i,n) cin >> x[i] >> y[i];
sort(x.begin(),x.end());
sort(y.begin(),y.end());
int ansx,ansy;
if (n%2 == 0){
ansx = (x[n/2-1]+x[n/2])/2;
ansy = (y[n/2-1]+y[n/2])/2;
}
else{
ansx = x[n/2];
ansy = y[n/2];
}
int ans = 0;
for (int i = 0; i < n;i++){
ans += abs(ansx-x[i])+abs(ansy-y[i]);
}
cout << ans << endl;
return 0;
}