結果

問題 No.2601 Very Poor
ユーザー inksamuraiinksamurai
提出日時 2024-01-12 21:42:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 2,187 ms
コンパイル使用メモリ 211,004 KB
実行使用メモリ 28,556 KB
最終ジャッジ日時 2024-03-20 19:46:17
合計ジャッジ時間 8,390 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 3 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 229 ms
28,556 KB
testcase_16 AC 225 ms
28,556 KB
testcase_17 AC 230 ms
28,556 KB
testcase_18 AC 228 ms
28,556 KB
testcase_19 AC 229 ms
28,556 KB
testcase_20 AC 230 ms
28,556 KB
testcase_21 AC 231 ms
28,556 KB
testcase_22 AC 230 ms
28,556 KB
testcase_23 AC 230 ms
28,556 KB
testcase_24 AC 231 ms
28,556 KB
testcase_25 AC 228 ms
28,556 KB
testcase_26 AC 229 ms
28,556 KB
testcase_27 AC 230 ms
28,556 KB
testcase_28 AC 231 ms
28,556 KB
testcase_29 AC 231 ms
28,556 KB
testcase_30 AC 231 ms
28,556 KB
testcase_31 AC 230 ms
28,556 KB
testcase_32 AC 230 ms
28,556 KB
testcase_33 AC 229 ms
28,556 KB
testcase_34 AC 231 ms
28,556 KB
testcase_35 AC 3 ms
6,676 KB
testcase_36 AC 3 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _4aNWZeC ios::sync_with_stdio(0),cin.tie(0)
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

void slv(){
	int n,tar;
	cin>>n>>tar;
	
	vi a(n);
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		a.pb(a[i]);
	}

	int n2=n*2;
	vi ps;
	rep(i,n2){
		ps.pb((!sz(ps)?0:ps.back())+a[i]);
	}
	set<int> st;
	int ans=0;
	per(i,n2){
		// -lo + ps[i] <= tar
		// ps[i] <= tar + lo
		st.insert(ps[i]);
		int lo=!i?0:ps[i-1];
		auto it=st.upper_bound(tar+lo);
		if(it!=st.begin()){
			it=prev(it);
			ans=max(ans,*it-lo);
		}
	}
	cout<<min(ans,ps[n-1])<<"\n";
}

signed main(){
_4aNWZeC;
	slv();
}
0