Submission #939709

# Submission time Handle Problem Language Result Execution time Memory
939709 2024-03-06T16:50:09 Z Litusiano Discharging (NOI20_discharging) C++17
11 / 100
89 ms 13520 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin>>n;
	vector<int> v(n); for(int& i : v) cin>>i;
	int s = v[0];
	int last = 0;
	int mx = v[0];
	for(int i = 1; i<n; i++){
		if(v[i] <= mx){
			s += mx;
		}
		else{
			int tmp = (i-last) * (v[i]-mx) + v[i];
			int tmp1 = (n-i)*mx + v[i];
			mx = v[i];
			// cerr<<tmp<<" "<<tmp1<<" "<<last<<endl;
			if(tmp <= tmp1){
				s+=tmp;
			}
			else{
				s+=tmp1; last = i;
			}
		}
	}
	cout<<s<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 74 ms 13268 KB Output is correct
2 Correct 74 ms 13392 KB Output is correct
3 Correct 72 ms 13388 KB Output is correct
4 Correct 72 ms 13388 KB Output is correct
5 Correct 89 ms 13408 KB Output is correct
6 Correct 76 ms 13520 KB Output is correct
7 Correct 74 ms 13256 KB Output is correct
8 Correct 73 ms 13412 KB Output is correct
9 Correct 73 ms 13408 KB Output is correct
10 Correct 76 ms 13396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -