提出 #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];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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 KiB

ジャッジ結果

セット名 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 KiB
001.txt AC 1 ms 3412 KiB
002.txt AC 12 ms 6508 KiB
003.txt AC 14 ms 6588 KiB
004.txt AC 13 ms 6580 KiB
005.txt AC 13 ms 6724 KiB
006.txt AC 13 ms 6580 KiB
007.txt AC 1 ms 3472 KiB
008.txt AC 1 ms 3392 KiB
009.txt AC 1 ms 3528 KiB
010.txt AC 8 ms 5064 KiB
011.txt AC 3 ms 3988 KiB
012.txt AC 7 ms 4796 KiB
013.txt AC 8 ms 5172 KiB
014.txt AC 9 ms 5472 KiB
015.txt AC 14 ms 6588 KiB
016.txt AC 14 ms 6592 KiB
017.txt AC 14 ms 6508 KiB
018.txt AC 15 ms 6544 KiB
019.txt AC 14 ms 6640 KiB
020.txt AC 14 ms 6516 KiB
021.txt AC 14 ms 6724 KiB
022.txt AC 14 ms 6584 KiB
023.txt AC 14 ms 6544 KiB
024.txt AC 14 ms 6572 KiB
example0.txt AC 1 ms 3444 KiB
example1.txt AC 1 ms 3520 KiB
example2.txt AC 1 ms 3408 KiB


2025-09-23 (火)
00:24:31 +00:00