Submission #63598856
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define all(a) begin(a),end(a)
#define sz(a) (int)(a).size()
const ll mod=998244353;
struct mint{
ll v;
mint():v(0){}
mint(ll val):v(val%mod){}
friend mint operator+(const mint&a,const mint&b){return a.v+b.v;}
friend mint operator-(const mint&a,const mint&b){return a.v-b.v;}
friend mint operator*(const mint&a,const mint&b){return a.v*b.v;}
ll val(){if(v<0)v+=mod;return v;}
};
vector<mint>power(2e6);
struct hanoi{
int size,fst;
vector<mint>ans,top;
vector<int>nec;
};
hanoi op(hanoi&a,hanoi&b){
if(a.nec[0]==-1)return b;
if(b.nec[0]==-1)return a;
vector<mint>ans(3),top(3);
vector<int>nec(3);
rep(i,0,3){
if(b.nec[i]==3)ans[i]=a.ans[i];
else ans[i]=a.ans[b.nec[i]]+(power[a.size+1]-2)*b.top[i]+b.ans[i]-(b.fst==b.nec[i]?0:power[a.size]-1);
}
rep(i,0,3){
if(b.nec[i]==3)top[i]=a.top[i];
else top[i]=a.top[b.nec[i]]+b.top[i]*power[a.size]-(b.fst==b.nec[i]?0:power[a.size-1]);
}
rep(i,0,3){
if(b.nec[i]==3)nec[i]=a.nec[i];
else if(a.nec[b.nec[i]]==3)nec[i]=b.nec[i];
else nec[i]=a.nec[b.nec[i]];
}
return hanoi{a.size+b.size,a.fst,ans,top,nec};
}
hanoi e(){
return hanoi{0,0,{0,0,0},{0,0,0},{-1,-1,-1}};
}
struct segtree{
ll n=1;
vector<hanoi>tree;
segtree(ll N){
while(n<N)n*=2;
tree.assign(2*n,e());
}
void set(ll i,hanoi&x){
i+=n;
tree[i]=x;
while(i>1){
i/=2;
tree[i]=op(tree[2*i],tree[2*i+1]);
}
}
hanoi prod(ll l,ll r){
l+=n;r+=n;
hanoi L=e(),R=e();
while(l<r){
if(l%2)L=op(L,tree[l]),l++;
if(r%2)r--,R=op(tree[r],R);
l/=2;r/=2;
}
return op(L,R);
}
hanoi get(ll i){return tree[i+n];}
};
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
ll N;cin>>N;
vector<ll>A(N);
rep(I,0,N)cin>>A[I];
ll a=0,b=-1e18;
rep(I,0,N){
ll c=a;
a=max(a+A[I],b);
b=c;
}
cout<<a<<endl;
}
Submission Info
Submission Time |
|
Task |
A - Operations on a Stack |
User |
TKTYI |
Language |
C++ 23 (gcc 12.2) |
Score |
400 |
Code Size |
2106 Byte |
Status |
AC |
Exec Time |
19 ms |
Memory |
20304 KB |
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 |
6 ms |
18504 KB |
001.txt |
AC |
7 ms |
18500 KB |
002.txt |
AC |
18 ms |
20304 KB |
003.txt |
AC |
18 ms |
20288 KB |
004.txt |
AC |
19 ms |
20164 KB |
005.txt |
AC |
19 ms |
20172 KB |
006.txt |
AC |
19 ms |
20164 KB |
007.txt |
AC |
7 ms |
18532 KB |
008.txt |
AC |
7 ms |
18444 KB |
009.txt |
AC |
6 ms |
18544 KB |
010.txt |
AC |
13 ms |
19332 KB |
011.txt |
AC |
8 ms |
18820 KB |
012.txt |
AC |
12 ms |
19424 KB |
013.txt |
AC |
14 ms |
19700 KB |
014.txt |
AC |
14 ms |
19600 KB |
015.txt |
AC |
19 ms |
20164 KB |
016.txt |
AC |
19 ms |
20136 KB |
017.txt |
AC |
19 ms |
20228 KB |
018.txt |
AC |
19 ms |
20236 KB |
019.txt |
AC |
19 ms |
20216 KB |
020.txt |
AC |
19 ms |
20208 KB |
021.txt |
AC |
19 ms |
20204 KB |
022.txt |
AC |
19 ms |
20156 KB |
023.txt |
AC |
19 ms |
20200 KB |
024.txt |
AC |
19 ms |
20164 KB |
example0.txt |
AC |
7 ms |
18600 KB |
example1.txt |
AC |
6 ms |
18404 KB |
example2.txt |
AC |
6 ms |
18492 KB |