提出 #63597440


ソースコード 拡げる

Copy
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,l,r) for(int i=(l);i>=(r);--i)
#define repn(i,n) for(int i=0;i<(n);++i)
#define sizc(x) ((int)(x).size())
#define allc(x) (x).begin(),(x).end()
#define fir first
#define sec second
constexpr int N = 2e5+5;
int n;
ll a[N];
ll f[N];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;

using ui = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,l,r) for(int i=(l);i>=(r);--i)
#define repn(i,n) for(int i=0;i<(n);++i)
#define sizc(x) ((int)(x).size())
#define allc(x) (x).begin(),(x).end()
#define fir first
#define sec second

constexpr int N = 2e5+5;

int n;
ll a[N];
ll f[N];

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

    cin>>n;
    rep(i,1,n)cin>>a[i];
    f[1]=a[1];
    rep(i,2,n)f[i]=max(f[i-1]+a[i],f[i-2]);
    cout<<f[n]<<'\n';
}

提出情報

提出日時
問題 A - Operations on a Stack
ユーザ KnownError_
言語 C++ 20 (gcc 12.2)
得点 400
コード長 653 Byte
結果 AC
実行時間 15 ms
メモリ 6724 KB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 28
セット名 テストケース
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, example0.txt, example1.txt, example2.txt
ケース名 結果 実行時間 メモリ
000.txt AC 1 ms 3416 KB
001.txt AC 1 ms 3412 KB
002.txt AC 12 ms 6508 KB
003.txt AC 14 ms 6588 KB
004.txt AC 13 ms 6580 KB
005.txt AC 13 ms 6724 KB
006.txt AC 13 ms 6580 KB
007.txt AC 1 ms 3472 KB
008.txt AC 1 ms 3392 KB
009.txt AC 1 ms 3528 KB
010.txt AC 8 ms 5064 KB
011.txt AC 3 ms 3988 KB
012.txt AC 7 ms 4796 KB
013.txt AC 8 ms 5172 KB
014.txt AC 9 ms 5472 KB
015.txt AC 14 ms 6588 KB
016.txt AC 14 ms 6592 KB
017.txt AC 14 ms 6508 KB
018.txt AC 15 ms 6544 KB
019.txt AC 14 ms 6640 KB
020.txt AC 14 ms 6516 KB
021.txt AC 14 ms 6724 KB
022.txt AC 14 ms 6584 KB
023.txt AC 14 ms 6544 KB
024.txt AC 14 ms 6572 KB
example0.txt AC 1 ms 3444 KB
example1.txt AC 1 ms 3520 KB
example2.txt AC 1 ms 3408 KB


2025-03-18 (火)
22:47:50 +00:00