提出 #4355871


ソースコード 拡げる

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int N,K;
int h[100010];

int main() {
  int i;

  cin >> N >> K;
  REP(i,N) scanf("%d", &h[i]);

  sort(h, h + N);
  reverse(h, h + N);
  int mn = (1<<30);
  for (i = 0; i < N - K + 1; i++) {
    mn = min(mn, h[i] - h[i+K-1]);
  }

  cout << mn << endl;

  return 0;
}

提出情報

提出日時
問題 C - Christmas Eve
ユーザ jyane
言語 C++14 (GCC 5.4.1)
得点 300
コード長 391 Byte
結果 AC
実行時間 19 ms
メモリ 640 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i,N) scanf("%d", &h[i]);
                              ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 10
セット名 テストケース
Sample a01, a02
All a01, a02, b03, b04, b05, b06, b07, b08, b09, b10
ケース名 結果 実行時間 メモリ
a01 AC 1 ms 256 KiB
a02 AC 1 ms 256 KiB
b03 AC 1 ms 256 KiB
b04 AC 14 ms 640 KiB
b05 AC 19 ms 640 KiB
b06 AC 19 ms 640 KiB
b07 AC 19 ms 640 KiB
b08 AC 19 ms 640 KiB
b09 AC 19 ms 640 KiB
b10 AC 18 ms 640 KiB