답안 #968192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968192 2024-04-23T08:25:03 Z willychan Real Mountains (CCO23_day1problem2) C++17
0 / 25
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds

const int MOD = 1e6+3;


int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	priority_queue<pair<int,int> ,vector<pair<int,int> >,greater<pair<int,int> > >	 pq;
	int ans = 0;
	int n;
	cin>>n;
	vector<int> arr(n);
	for(int i=0;i<n;i++) cin>>arr[i];
	for(int i=0;i<n;i++) pq.push({arr[i],i});
	while(pq.size()){
		pair<int,int> cur = pq.top();
		pq.pop();
		if(cur.first!=arr[cur.second]) continue;
		int r = arr[cur.second];
		int l = arr[cur.second];
		for(int i=cur.second;i<n;i++){
			if(arr[i]>arr[cur.second]) {
				r = arr[i];
				break;
			}
		}
		for(int i=cur.second;i>=0;i--){
			if(arr[i]>arr[cur.second]) {
				l = arr[i];
				break;
			}
		}
		if(r==arr[cur.second] || l==arr[cur.second]) continue;
		int a = min(r,l);
		if(a==arr[cur.second]) break;
		ans+=l+r+arr[cur.second];
		ans%=MOD;
		arr[cur.second]++;
		pq.push({arr[cur.second],cur.second});
	}
	cout<<ans<<"\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -