結果
| 問題 |
No.2517 Right Triangles on Circle
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-10-27 23:44:41 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 790 bytes |
| コンパイル時間 | 394 ms |
| コンパイル使用メモリ | 30,080 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 15:32:53 |
| 合計ジャッジ時間 | 2,305 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#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 m = 0;
int a[300000] = {};
int res = 0;
long long ans = 0LL;
int idx = 0;
res = scanf("%d", &n);
res = scanf("%d", &m);
for (int i = 0; i < n; i++) {
res = scanf("%d", a+i);
}
if (m%2 == 1) {
printf("0\n");
return 0;
}
qsort(a, n, sizeof(int), cmp_int);
for (int i = 0; i < n; i++) {
while (idx < n && a[idx] < a[i]+m/2) {
idx++;
}
if (idx < n && a[idx] == a[i]+m/2) {
ans += 1LL;
}
}
ans *= (long long)(n-2);
printf("%lld\n", ans);
return 0;
}
chro_96