結果
| 問題 | No.9 モンスターのレベル上げ |
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-01-14 18:35:01 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 4,023 bytes |
| コンパイル時間 | 1,181 ms |
| コンパイル使用メモリ | 114,236 KB |
| 実行使用メモリ | 52,420 KB |
| 最終ジャッジ日時 | 2024-12-21 12:44:31 |
| 合計ジャッジ時間 | 44,719 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 TLE * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
class Program
{
static void Main(string[]args)
{
Magatro m = new Magatro();
m.Scan();
m.Solve();
}
}
public class Scanner
{
private StreamReader Sr;
private string[] S;
private int Index;
private const char Separator=' ';
public Scanner()
{
Index = 0;
S = new string[0];
Sr = new StreamReader(Console.OpenStandardInput());
}
private string[] Line()
{
return Sr.ReadLine().Split(Separator);
}
public string Next()
{
string result;
if (Index >= S.Length)
{
S = Line();
Index = 0;
}
result = S[Index];
Index++;
return result;
}
public int NextInt()
{
return int.Parse(Next());
}
public double NextDouble()
{
return double.Parse(Next());
}
public long NextLong()
{
return long.Parse(Next());
}
public bool ScanToEnd(ref string s)
{
if (Sr.EndOfStream)
{
return false;
}
else
{
s = Sr.ReadLine();
return true;
}
}
}
public class Magatro
{
private int N;
private int[] A, B;
public void Scan()
{
Scanner sc = new Scanner();
N = sc.NextInt();
A = new int[N];
B = new int[N];
for(int i = 0; i < N; i++)
{
A[i] = sc.NextInt();
}
for(int i = 0; i < N; i++)
{
B[i] = sc.NextInt();
}
}
public void Solve()
{
int ans = int.MaxValue;
for(int i = 0; i < N; i++)
{
ans = Math.Min(Ans(i), ans);
}
Console.WriteLine(ans);
}
private int Ans(int n)
{
var Q = new PriorityQueue<My>(Compare);
for(int i = 0; i < N; i++)
{
Q.Enqueue(new My(A[i]));
}
for(int i = n; i < N; i++)
{
My t = Q.Dequeue();
t.Cnt++;
t.Level += B[i] / 2;
Q.Enqueue(t);
}
for(int i = 0; i < n; i++)
{
My t = Q.Dequeue();
t.Cnt++;
t.Level += B[i] / 2;
Q.Enqueue(t);
}
var L = Q.list;
int max = 0;
for(int i = 0; i < L.Count; i++)
{
max = Math.Max(max, L[i].Cnt);
}
return max;
}
private int Compare(My a,My b)
{
if (a.Level < b.Level) return -1;
else if (b.Level < a.Level) return 1;
else
{
if (a.Cnt < b.Cnt)
{
return -1;
}
else if(a.Cnt>b.Cnt)
{
return 1;
}
else
{
return 0;
}
}
}
}
struct My
{
public int Cnt, Level;
public My(int level)
{
Level = level;
Cnt = 0;
}
}
public class PriorityQueue<T>
{
public List<T> list = new List<T>();
public IComparer<T> comp = Comparer<T>.Default;
class Comparer : IComparer<T>
{
Comparison<T> comparison;
public Comparer(Comparison<T> comparison) { this.comparison = comparison; }
public int Compare(T x, T y) { return comparison(x, y); }
}
public PriorityQueue() { }
public PriorityQueue(Comparison<T> comp) { this.comp = new Comparer(comp); }
public void Enqueue(T item) { int i = list.BinarySearch(item, comp); list.Insert(i < 0 ? ~i : i, item); }
public T Dequeue() { T r = list[0]; list.RemoveAt(0); return r; }
public T Peek() { return list[0]; }
public int Count { get { return list.Count; } }
public T this[int i] { get { return list[i]; } set { list[i] = value; } }
}
mban