Submission #63598307
Source Code Expand
// Homura Akemi a.k.a. Starrykiller (/user/235125)
// I love Madoka Kaname forever!
#include <bits/stdc++.h>
using namespace std;
auto range(auto l, auto r) { return views::iota(l,r); }
auto rev=views::reverse;
_GLIBCXX_ALWAYS_INLINE void chmax(auto &a, auto b) { a=max(a,b); }
_GLIBCXX_ALWAYS_INLINE void chmin(auto &a, auto b) { a=min(a,b); }
#define int long long
constexpr int MAXN=2e5+10;
int f[MAXN], a[MAXN];
int n;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cin>>n;
for (int i=1; i<=n; ++i) cin>>a[i];
f[n+1]=0; f[n+2]=-1e18;
for (int i=n; i; --i) {
f[i]=max(a[i]+f[i+1],f[i+2]);
}
cout<<f[1]<<'\n';
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Operations on a Stack |
| User | Starrykiller |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 725 Byte |
| Status | AC |
| Exec Time | 15 ms |
| Memory | 6720 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 1 ms | 3392 KiB |
| 001.txt | AC | 1 ms | 3460 KiB |
| 002.txt | AC | 13 ms | 6580 KiB |
| 003.txt | AC | 13 ms | 6592 KiB |
| 004.txt | AC | 13 ms | 6588 KiB |
| 005.txt | AC | 13 ms | 6648 KiB |
| 006.txt | AC | 14 ms | 6592 KiB |
| 007.txt | AC | 1 ms | 3408 KiB |
| 008.txt | AC | 1 ms | 3372 KiB |
| 009.txt | AC | 1 ms | 3408 KiB |
| 010.txt | AC | 8 ms | 5116 KiB |
| 011.txt | AC | 3 ms | 3992 KiB |
| 012.txt | AC | 7 ms | 4864 KiB |
| 013.txt | AC | 8 ms | 5220 KiB |
| 014.txt | AC | 9 ms | 5324 KiB |
| 015.txt | AC | 14 ms | 6572 KiB |
| 016.txt | AC | 15 ms | 6536 KiB |
| 017.txt | AC | 15 ms | 6584 KiB |
| 018.txt | AC | 14 ms | 6720 KiB |
| 019.txt | AC | 14 ms | 6588 KiB |
| 020.txt | AC | 14 ms | 6584 KiB |
| 021.txt | AC | 14 ms | 6720 KiB |
| 022.txt | AC | 14 ms | 6576 KiB |
| 023.txt | AC | 14 ms | 6508 KiB |
| 024.txt | AC | 14 ms | 6628 KiB |
| example0.txt | AC | 1 ms | 3452 KiB |
| example1.txt | AC | 1 ms | 3472 KiB |
| example2.txt | AC | 1 ms | 3464 KiB |