結果
問題 | No.2601 Very Poor |
ユーザー |
![]() |
提出日時 | 2024-07-15 15:32:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 1,732 bytes |
コンパイル時間 | 5,152 ms |
コンパイル使用メモリ | 311,112 KB |
実行使用メモリ | 9,604 KB |
最終ジャッジ日時 | 2024-07-15 15:32:14 |
合計ジャッジ時間 | 8,519 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<vi> vvi; typedef vector<vll> vvll; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define _rrep(i,n) rrepi(i,n-1,-1) #define rrepi(i,a,b) for(int i=int(a);i>int(b);--i) #define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define SORT(x) sort(all(x)) #define REVERSE(x) reverse(all(x)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } ostream& operator<<(ostream& os, const modint998244353& a) { return os << a.val(); } ostream& operator<<(ostream& os, const modint1000000007& a) { return os << a.val(); } template<class T> istream& operator>>(istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; } template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (const T& x : vec) os << x << ' '; return os; } int main() { int N, X; cin >> N >> X; vll A(N); cin >> A; A.resize(2*N); rep(i, N, 2*N) A[i] = A[i-N]; vll acc(2*N+1); rep(i, 0, 2*N) acc[i+1] = acc[i]+A[i]; auto it = acc.begin(); ll ans = 0; rep(i, N) { // iからとれるだけとる int n = upper_bound(it, it+N+1, *it+X) - acc.begin(); chmax(ans, acc[n-1] - *it); it++; } cout << ans << endl; }