結果
| 問題 |
No.1673 Lamps on a line
|
| コンテスト | |
| ユーザー |
Maeda
|
| 提出日時 | 2025-04-07 15:31:06 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 414 ms / 2,000 ms |
| コード長 | 1,223 bytes |
| コンパイル時間 | 9,671 ms |
| コンパイル使用メモリ | 171,084 KB |
| 実行使用メモリ | 52,776 KB |
| 最終ジャッジ日時 | 2025-04-07 15:31:27 |
| 合計ジャッジ時間 | 14,383 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (112 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
class Program
{
static void Main(string[] args)
{
string[] str = Console.ReadLine().Split(' ');
int[] list = Enumerable.Repeat(0, int.Parse(str[0])).ToArray();
List<int> onList = new List<int>();
int count = 0;
for(int i= 0; i < int.Parse(str[1]); i++)
{
string[] change = Console.ReadLine().Split(' ');
var ans = LampChange(list,count, int.Parse(change[0]), int.Parse(change[1]));
list = ans.list;
count = ans.count;
onList.Add(count);
}
foreach (int i in onList)
{
Console.WriteLine(i);
}
}
private static(int count, int[] list) LampChange(int[] list,int count, int v1, int v2)
{
for(int i = v1-1; i <= v2-1; i++)
{
if (list[i] == 0)
{
list[i] = 1;
count++;
}
else
{
list[i] = 0;
count--;
}
}
return (count,list);
}
}
Maeda