結果
| 問題 |
No.2315 Flying Camera
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-05-26 23:01:22 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 735 bytes |
| コンパイル時間 | 948 ms |
| コンパイル使用メモリ | 30,208 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-25 10:05:21 |
| 合計ジャッジ時間 | 1,192 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
int cmp_int (const void *ap, const void *bp) {
int a = *(int *)ap;
int b = *(int *)bp;
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return 0;
}
int main () {
int n = 0;
int x[300] = {};
int y[300] = {};
int res = 0;
int ans = 0;
res = scanf("%d", &n);
for (int i = 0; i < n; i++) {
res = scanf("%d", x+i);
res = scanf("%d", y+i);
}
qsort(x, n, sizeof(int), cmp_int);
qsort(y, n, sizeof(int), cmp_int);
for (int i = 0; i < n/2; i++) {
ans += x[n/2]-x[i];
ans += y[n/2]-y[i];
}
for (int i = n/2; i < n; i++) {
ans += x[i]-x[n/2];
ans += y[i]-y[n/2];
}
printf("%d\n", ans);
return 0;
}
chro_96