結果
| 問題 | No.3681 心の沸騰石 |
| コンテスト | |
| ユーザー |
鳩でもわかるC#
|
| 提出日時 | 2026-09-05 14:55:49 |
| 言語 | C# (.NET 10.0.400) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| + 293µs | |
| コード長 | 4,951 bytes |
| 記録 | |
| コンパイル時間 | 5,200 ms |
| コンパイル使用メモリ | 174,732 KB |
| 実行使用メモリ | 194,316 KB |
| 最終ジャッジ日時 | 2026-09-05 14:56:00 |
| 合計ジャッジ時間 | 7,316 ms |
|
ジャッジサーバーID (参考情報) |
judge5_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (90 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
class Program
{
static string ReadLine() => Console.ReadLine().Trim();
static int ReadInt() => int.Parse(ReadLine());
static long ReadLong() => long.Parse(ReadLine());
static int[] ReadIntArray() { string str = ReadLine(); return str != "" ? str.Split().Select(_ => int.Parse(_)).ToArray() : new int[0]; }
static long[] ReadLongArray() { string str = ReadLine(); return str != "" ? str.Split().Select(_ => long.Parse(_)).ToArray() : new long[0]; }
static (int, int) ReadInt2() { int[] vs = ReadIntArray(); return (vs[0], vs[1]); }
static (int, int, int) ReadInt3() { int[] vs = ReadIntArray(); return (vs[0], vs[1], vs[2]); }
static (int, int, int, int) ReadInt4() { int[] vs = ReadIntArray(); return (vs[0], vs[1], vs[2], vs[3]); }
static (int, int, int, int, int) ReadInt5() { int[] vs = ReadIntArray(); return (vs[0], vs[1], vs[2], vs[3], vs[4]); }
static (long, long) ReadLong2() { long[] vs = ReadLongArray(); return (vs[0], vs[1]); }
static (long, long, long) ReadLong3() { long[] vs = ReadLongArray(); return (vs[0], vs[1], vs[2]); }
static void Main()
{
SourceExpander.Expander.Expand();
(long R, long P, long Q) = ReadInt3();
(long A, long B, long C, long D) = ReadInt4();
long ng = (A + B + C + D) / 3 + 10;
long ok = 0;
long aa = AtCoder.StlFunction.BinarySearch(ok, ng, mid => F(mid));
Console.WriteLine(aa);
bool F(long x)
{
long husoku = 0;
if(x - A > 0)
husoku += x - A;
if (x - B > 0)
husoku += x - B;
if (x - C > 0)
husoku += x - C;
long jouyo = 0;
if (A - x > 0)
jouyo += A - x;
if (B - x > 0)
jouyo += B - x;
if (C - x > 0)
jouyo += C - x;
jouyo += D;
if (husoku > jouyo)
return false;
return husoku * Q + x * P <= R;
}
}
void F11()
{
(int N, int K) = ReadInt2();
long[] A = ReadLongArray();
long[] dp = new long[K + 1];
for (int i = 0; i < N; i++)
{
long v = A[i];
long[] n_dp = (long[])dp.Clone();
for (int j = 0; j <= K; j++)
{
if (j + 1 <= K && n_dp[j + 1] < dp[j] + v)
n_dp[j + 1] = dp[j] + v;
if (n_dp[j] < dp[j])
n_dp[j] = dp[j];
}
dp = n_dp;
}
//Console.WriteLine(dp.Max());
}
}
#region Expanded by https://github.com/kzrnm/SourceExpander
namespace AtCoder{public static class StlFunction{public struct NextPermutationEnumerator<T>:IEnumerator<T[]>,IEnumerable<T[]>where T:IComparable<T>{internal readonly IEnumerable<T>_orig;internal NextPermutationEnumerator(IEnumerable<T>orig){_orig=orig;Current=null;}public T[]Current{get;private set;}[MethodImpl(256)]public bool MoveNext(){if(Current==null){Current=_orig.ToArray();return true;}return NextPermutation(Current);}public void Reset()=>Current=null;object IEnumerator.Current=>Current;void IDisposable.Dispose(){}[MethodImpl(256)]public NextPermutationEnumerator<T>GetEnumerator()=>this;IEnumerator<T[]>IEnumerable<T[]>.GetEnumerator()=>this;IEnumerator IEnumerable.GetEnumerator()=>this;}[MethodImpl(256)]public static bool NextPermutation<T>(T[]array)where T:IComparable<T> =>NextPermutation(array.AsSpan());[MethodImpl(256)]public static bool NextPermutation<T>(Span<T>span)where T:IComparable<T>{int i;for(i=span.Length-2;i>=0;i--)if(span[i].CompareTo(span[i+1])<0)break;if(i<0)return false;int j;for(j=span.Length-1;j>=0;j--)if(span[i].CompareTo(span[j])<0)break;(span[i],span[j])=(span[j],span[i]);span.Slice(i+1,span.Length-i-1).Reverse();return true;}[MethodImpl(256)]public static NextPermutationEnumerator<T>Permutations<T>(IEnumerable<T>orig)where T:IComparable<T> =>new NextPermutationEnumerator<T>(orig);private struct DefaultComparer<T>:IComparer<T>where T:IComparable<T>{[MethodImpl(256)]public int Compare(T x,T y)=>x.CompareTo(y);}[MethodImpl(256)]public static int BinarySearch(int ok,int ng,Predicate<int>Ok){while(Math.Abs(ok-ng)>1){var m=(ok+ng)>>1;if(Ok(m))ok=m;else ng=m;}return ok;}[MethodImpl(256)]public static long BinarySearch(long ok,long ng,Predicate<long>Ok){while(Math.Abs(ok-ng)>1){var m=(ok+ng)>>1;if(Ok(m))ok=m;else ng=m;}return ok;}}}
namespace SourceExpander{public class Expander{[Conditional("EXP")]public static void Expand(string inputFilePath=null,string outputFilePath=null,bool ignoreAnyError=true){}public static string ExpandString(string inputFilePath=null,bool ignoreAnyError=true){return "";}}}
#endregion Expanded by https://github.com/kzrnm/SourceExpander
鳩でもわかるC#