結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
sdkgd
|
| 提出日時 | 2025-03-01 15:59:40 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 2,296 bytes |
| コンパイル時間 | 3,341 ms |
| コンパイル使用メモリ | 280,624 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-03-01 15:59:45 |
| 合計ジャッジ時間 | 4,575 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#include <cassert>
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define nall(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>; //sample vvvl A(N,vvl(N,vl(N,0)));
const ll POW2=1e2,POW5=1e5,POW6=1e6,POW9=1e9,POW12=1e12,POW15=1e15,POW18=1e18;
const int iINF = 1<<30; const ll INF = 1LL<<62; const ull UINF = 1LL<<63; const ld ldINF=(ld)POW15;
const ll mod=998244353; const ll mod2=1000000007;
const ld PI=3.141592653589793238462643;
vector<ll> dy={-1,0,1,0},dx={0,1,0,-1},dy8={-1,-1,-1,0,0,1,1,1},dx8={-1,0,1,-1,1,-1,0,1};
template<class T> using pq = priority_queue<T,vector<T>>;
template<class T> using pq_g = priority_queue<T,vector<T>,greater<T>>;
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; }
template<class T>void vc_unique(vector<T> &v){v.erase(unique(v.begin(),v.end()),v.end());}
template<class T>void sdebug(string s, T& a){cout<<s<<": "<<a<<endl;}
template<class T>void vdebug(string s, vector<T> &v){
ll W=v.size();
cout<<"--------------------------"<<endl;
cout<<s<<": "<<endl;
for(ll i=0;i<W;i++){
if(v[i]>POW15) cout<<"INF ";
else if(v[i]<-POW15) cout<<"-INF ";
else cout<<v[i]<<" ";
}
cout<<endl;
}
template<class T>void vvdebug(string s, vector<vector<T>> &v){
ll H=v.size();
cout<<"--------------------------"<<endl;
cout<<s<<": "<<endl;
for(ll i=0;i<H;i++){
for(auto e:v[i]){
if(e>POW15) cout<<"INF ";
else if(e<-POW15) cout<<"-INF ";
else cout<<e<<" ";
}
cout<<endl;
}
}
ll roundUp(ll n, ll m){
if(n>=0 && n%m!=0) return n/m+1;
else return n/m;
}
ll truncate(ll n, ll m){
if(n<0 && n%m!=0) return n/m-1;
else return n/m;
}
int main() {
std::cin.tie(0)->sync_with_stdio(0);
ll N;cin>>N;
vl V(N);for(ll i=0;i<N;i++) cin>>V[i];
vvl dp(N+1,vl(2,0)); dp[0][0]=0;dp[0][1]=V[0];
for(ll i=1;i<N;i++){
dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
dp[i][1]=dp[i-1][0]+V[i];
}
cout<<max(dp[N-1][0],dp[N-1][1])<<endl;
}
sdkgd