# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
285021 | 2020-08-28T09:02:28 Z | mosiashvililuka | Discharging (NOI20_discharging) | C++14 | 219 ms | 39800 KB |
#include<bits/stdc++.h> using namespace std; int a,b,c,d,e,i,j,ii,jj,zx,xc,f[1000009],mx,rg[1000009]; long long dp[1000009]; multiset <long long> s; multiset <long long>::iterator it; vector <long long> v[1000009]; stack <int> st; int main(){ //ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); scanf("%d",&a); scanf("\n"); for(i=1; i<=a; i++) scanf("%d",&f[i]); mx=0; for(i=1; i<=a; i++){ if(mx<f[i]) mx=f[i]; dp[i]=mx*a; while(st.size()>0&&f[st.top()+1]<=f[i]){ //zx=dp[st.top()]+(f[i]-f[st.top()+1])*(a-st.top()); zx=dp[st.top()]+f[i]*(a-st.top()); if(dp[i]>zx) dp[i]=zx; st.pop(); } if(st.size()>0){ zx=dp[st.top()]+f[st.top()+1]*(a-st.top()); if(dp[i]>zx) dp[i]=zx; } if(dp[i]>dp[i-1]+f[i]*(a-i+1)) dp[i]=dp[i-1]+f[i]*(a-i+1); //cout<<dp[i]<<endl; st.push(i-1); } cout<<dp[a]; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23808 KB | Output is correct |
2 | Correct | 16 ms | 23936 KB | Output is correct |
3 | Incorrect | 15 ms | 23808 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 23808 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 23808 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 219 ms | 39800 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23808 KB | Output is correct |
2 | Correct | 16 ms | 23936 KB | Output is correct |
3 | Incorrect | 15 ms | 23808 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23808 KB | Output is correct |
2 | Correct | 16 ms | 23936 KB | Output is correct |
3 | Incorrect | 15 ms | 23808 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |