Submission #15265

#TimeUsernameProblemLanguageResultExecution timeMemory
15265ainta달리는 게임 (kriii3_E)C++98
70 / 70
177 ms12920 KiB
#include<stdio.h> long long S[1010000], SS, Res; int w[1010000]; int n; int main(){ int i, j; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&w[i]); S[i]=S[i-1]+w[i]; } for(i=n;i>=1;i--){ if(w[i] > 0){ SS = 0; for(j=i-1;j>=0;j--){ if(S[i]<S[j])break; SS += S[i]-S[j]; } Res += SS; i=j+1; } } printf("%lld\n",Res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...