結果
| 問題 | No.3527 Minimum Abs Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-08 22:42:08 |
| 言語 | C# (.NET 10.0.201) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,427 bytes |
| 記録 | |
| コンパイル時間 | 10,311 ms |
| コンパイル使用メモリ | 173,640 KB |
| 実行使用メモリ | 200,776 KB |
| 最終ジャッジ日時 | 2026-05-08 22:42:28 |
| 合計ジャッジ時間 | 17,036 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 24 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (91 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
static int NN => int.Parse(ReadLine());
static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
public static void Main()
{
Solve();
}
static void Solve()
{
var n = NN;
var a = NList;
var b = NList;
var list = new List<(long ch, long pa)>();
for (var i = 0; i < n; ++i)
{
if (a[i] > 0) list.Add((b[i], a[i]));
else if (a[i] < 0) list.Add((-b[i], -a[i]));
}
list.Sort((l, r) => (l.ch * r.pa).CompareTo(r.ch * l.pa));
if (list.Count % 2 == 1) Output(list[list.Count / 2]);
else Output(list[list.Count / 2 - 1]);
}
static void Output((long ch, long pa) li)
{
var mod = 1_000_000_007;
WriteLine(li.ch * Exp(li.pa, mod - 2, mod) % mod);
}
static long Exp(long n, long p, int mod)
{
long _n = n % mod;
var _p = p;
var result = 1L;
if ((_p & 1) == 1) result *= _n;
while (_p > 0)
{
_n = _n * _n % mod;
_p >>= 1;
if ((_p & 1) == 1) result = result * _n % mod;
}
return result;
}
}