Submission

Status:

TT---TT-TT

Subtask/Task Score:

0/100

Score: 0

User: Sea

Problemset: ปริมาตรน้ำท่วม

Language: cpp

Time: 2.095 second

Submitted On: 2026-11-21 22:43:42

#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, sum = 0;
	cin >> n;
	int arr[n];
	for(int i = 0 ; i < n ; i++){
		cin >> arr[i];
	}
	
	int left = 1, right = n - 2;
	int lmax = arr[left], rmax = arr[right];
	
	while(left < right){
		if(lmax < rmax){
			left++;
			sum = lmax;
		}
		else if(lmax > rmax){
			right--;
			sum = rmax;
		}
	}
	
	cout << sum;
	
	return 0;
}