結果
問題 | No.2601 Very Poor |
ユーザー |
![]() |
提出日時 | 2024-02-05 17:35:35 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 1,212 bytes |
コンパイル時間 | 9,003 ms |
コンパイル使用メモリ | 167,512 KB |
実行使用メモリ | 187,420 KB |
最終ジャッジ日時 | 2024-09-30 06:41:51 |
合計ジャッジ時間 | 12,790 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (83 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System.Collections; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; internal class Program { private const long mod = 998244353; public static void Main(string[] args) { int[] line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int n = line[0]; int x = line[1]; int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); long sum = 0; for (int i = 0; i < n; i++) sum += a[i]; if (sum <= x) { Console.WriteLine(sum); return; } int r = 0; sum = 0; long ans = 0; for (int l = 0; l < n; l++) { while (sum + a[r] <= x) { sum += a[r]; r++; if (r == n) r = 0; } //Console.WriteLine("{0},{1}",l,sum); ans = Math.Max(ans, sum); sum -= a[l]; } Console.WriteLine(ans); } public static List<int> mkar(int n, int val) { List<int> res = new List<int>(n); for(int i=0;i<n;i++)res.Add(val); return res; } }