Submission #939680

# Submission time Handle Problem Language Result Execution time Memory
939680 2024-03-06T16:35:19 Z Litusiano Discharging (NOI20_discharging) C++17
11 / 100
89 ms 18112 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 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 76 ms 17720 KB Output is correct
2 Correct 80 ms 17856 KB Output is correct
3 Correct 75 ms 17748 KB Output is correct
4 Correct 74 ms 17748 KB Output is correct
5 Correct 83 ms 17864 KB Output is correct
6 Correct 75 ms 17748 KB Output is correct
7 Correct 74 ms 18108 KB Output is correct
8 Correct 76 ms 17744 KB Output is correct
9 Correct 89 ms 18112 KB Output is correct
10 Correct 86 ms 17748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -