結果
| 問題 |
No.1673 Lamps on a line
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2021-09-11 07:06:24 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 119 ms / 2,000 ms |
| コード長 | 822 bytes |
| コンパイル時間 | 3,250 ms |
| コンパイル使用メモリ | 108,120 KB |
| 実行使用メモリ | 32,508 KB |
| 最終ジャッジ日時 | 2024-06-22 08:22:16 |
| 合計ジャッジ時間 | 3,311 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
public class Hello
{
static void Main()
{
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var q = int.Parse(line[1]);
getAns(n, q);
}
static void getAns(int n, int q)
{
var ans = new int[q];
var on = new bool[n];
var count = 0;
for (int i = 0; i < q; i++)
{
string[] line = Console.ReadLine().Trim().Split(' ');
var L = int.Parse(line[0]) - 1;
var r = int.Parse(line[1]) - 1;
for (int j = L; j <= r; j++)
{
if (on[j]) { on[j] = false; count--; }
else { on[j] = true; count++; }
}
ans[i] = count;
}
Console.WriteLine(string.Join("\n", ans));
}
}
bluemegane