結果
| 問題 |
No.3284 Picnic with Friends
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-26 23:10:05 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,907 bytes |
| コンパイル時間 | 9,090 ms |
| コンパイル使用メモリ | 167,752 KB |
| 実行使用メモリ | 157,792 KB |
| 最終ジャッジ日時 | 2025-09-26 23:10:27 |
| 合計ジャッジ時間 | 21,824 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 1 -- * 19 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (104 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
#nullable enable
#region
var _input = Array.Empty<string>();
var _iter = 0;
string String()
{
while (_iter >= _input.Length) (_input, _iter) = (Console.ReadLine()!.Split(' '), 0);
return _input[_iter++];
}
T I<T>() where T : IParsable<T> => T.Parse(String(), null);
#endregion
static T[] Range<T>(int n, Func<T> F) => Enumerable.Range(0, n).Select(_ => F()).ToArray();
var n = I<int>();
var sz = Range(n, I<long>);
var sd = new Dictionary<long, int>();
var svz = sz.Distinct().Order().ToArray();
foreach (var s in svz) sd[s] = sd.Count;
var q = I<int>();
var bag = new Bag<long>();
var l = -1L;
var r = -1L;
for (var i = 0; i < q; i++)
{
var t = I<long>();
var f = I<long>();
if (r < t)
{
if (r >= 0) bag.Add(r - l);
l = t;
r = l + f;
}
else r += f;
}
bag.Add(r - l);
var sns = new long[n];
foreach (var (k, v) in bag._dictionary)
{
for (var i = 0; i < svz.Length; i++)
{
var s = svz[i];
var z = (k * 2 + 1) / (s * 2);
if (z == 0) break;
sns[i] += z * v;
}
}
var ans = new long[n];
for (var i = 0; i < n; i++)
{
var s = sz[i];
ans[i] = sns[sd[s]];
}
Console.WriteLine(string.Join(Environment.NewLine, ans));
class Bag<K> where K : notnull
{
public readonly Dictionary<K, int> _dictionary = new();
public void Add(K key)
{
var dictionary = _dictionary;
if (dictionary.TryGetValue(key, out var count)) dictionary[key] = count + 1;
else dictionary[key] = 1;
}
public bool Remove(K key)
{
var dictionary = _dictionary;
if (!dictionary.TryGetValue(key, out var count)) return false;
if (count == 1) dictionary.Remove(key);
else dictionary[key] = count - 1;
return true;
}
public int this[K key] => _dictionary.TryGetValue(key, out var count) ? count : 0;
public int CountKeys => _dictionary.Count;
}