結果
問題 | No.2601 Very Poor |
ユーザー |
|
提出日時 | 2024-01-12 22:01:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 882 bytes |
コンパイル時間 | 1,540 ms |
コンパイル使用メモリ | 166,176 KB |
実行使用メモリ | 9,904 KB |
最終ジャッジ日時 | 2024-09-30 06:22:57 |
合計ジャッジ時間 | 4,048 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<bits/stdc++.h> #include<math.h> #include <numeric> #include <random> #include<map> #include<queue> #include<deque> #include <bitset> #include<stack> #include<set> #define int long long using namespace std; #define all(x) (x).begin(),(x).end() #define rep(i,n) for (int i=0;i<(n);++i) #define prep(i,n) for (int i=1;i<=(n);++i) #define ep(i,j,n) for (int i=j+1;i<=(n);++i) int INF = 900000000000000; int mod=998244353; signed main(){ int n,x;cin>>n>>x; int m=0; int a[2*n]; int b[2*n+10];b[0]=0; rep(i,n){cin>>a[i];m+=a[i];} rep(i,n){a[i+n]=a[i];} rep(i,2*n){b[i+1]=b[i]+a[i];} int ans=0; if(m<=x){cout<<m;return 0;} rep(i,n){ int pos=lower_bound(b,b+2*n,m-x+b[i])-b; if(pos-i>n){continue;} ans=max(ans,m+b[i]-b[pos]); // if(m-b[pos]-b[i]==9){cout<<b[pos]<<endl;} } cout<<ans; }