Submission #16610

#TimeUsernameProblemLanguageResultExecution timeMemory
16610eaststar달리는 게임 (kriii3_E)C++14
70 / 70
128 ms8896 KiB
#include <stdio.h> int a[1000010],chk[1000010]; long long ans,s,cnt; int main(){ int i,n; scanf("%d",&n); for(i=1;i<=n;++i)scanf("%d",a+i); for(;i;){ for(;i&&a[i]<=0;--i); for(s=0;i&&a[i]+s>0;s+=a[i--])chk[i]=1; } for(i=1;i<=n;++i){ for(cnt=1;i<=n&&chk[i];)ans+=a[i++]*(cnt++); } printf("%lld",ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...