結果
| 問題 |
No.21 平均の差
|
| ユーザー |
|
| 提出日時 | 2022-06-07 11:01:21 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 5,000 ms |
| コード長 | 1,184 bytes |
| コンパイル時間 | 798 ms |
| コンパイル使用メモリ | 107,916 KB |
| 実行使用メモリ | 25,796 KB |
| 最終ジャッジ日時 | 2024-09-21 04:51:56 |
| 合計ジャッジ時間 | 1,425 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
namespace yukicoder
{
class Program
{
static void Main(string[] args)
{
//N行目
int N = int.Parse(Console.ReadLine());
//Kグループに振り分ける
int K = int.Parse(Console.ReadLine());
int[] a = new int[N];
//nを配列に入れる
for(int i=0;i<N;i++)
{
//数字 N個入力する
int n = int.Parse(Console.ReadLine());
a[i] = n;
}
//nを小さい順に並び替え
for(int i=0;i<N;i++)
{
for(int j=0;j<i;j++)
{
if (a[i - 1] > a[i])
{
int temp = a[i];
a[i] = a[i - 1];
a[i - 1] = temp;
i = 0;
}
}
}
int ans = 0;
//ソートした最小と最大を引く
ans = a[N-1] - a[0];
//表示は文字列にする
Console.WriteLine(ans.ToString());
}
}
}