結果

問題 No.2315 Flying Camera
ユーザー zezerozezero
提出日時 2023-05-26 21:30:07
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 3,446 ms
コンパイル使用メモリ 168,084 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 05:00:55
合計ジャッジ時間 4,478 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0