結果

問題 No.2601 Very Poor
ユーザー aa
提出日時 2024-01-12 22:01:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 166,020 KB
実行使用メモリ 9,768 KB
最終ジャッジ日時 2024-03-20 19:47:32
合計ジャッジ時間 4,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 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 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 77 ms
9,768 KB
testcase_16 AC 77 ms
9,768 KB
testcase_17 AC 77 ms
9,768 KB
testcase_18 AC 77 ms
9,768 KB
testcase_19 AC 77 ms
9,768 KB
testcase_20 AC 76 ms
9,768 KB
testcase_21 AC 77 ms
9,768 KB
testcase_22 AC 77 ms
9,768 KB
testcase_23 AC 77 ms
9,768 KB
testcase_24 AC 77 ms
9,768 KB
testcase_25 AC 77 ms
9,768 KB
testcase_26 AC 77 ms
9,768 KB
testcase_27 AC 76 ms
9,768 KB
testcase_28 AC 77 ms
9,768 KB
testcase_29 AC 77 ms
9,768 KB
testcase_30 AC 77 ms
9,768 KB
testcase_31 AC 77 ms
9,768 KB
testcase_32 AC 77 ms
9,768 KB
testcase_33 AC 77 ms
9,768 KB
testcase_34 AC 77 ms
9,768 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0