Thông tin
Số bài đã giải: 0
Performance Points: 0,00 #1280
Active contests: 1/3
Đóng góp: 0
include <bits/stdc++.h>
using namespace std; int main() { //freopen("B3ND.INP", "r", stdin); //freopen("B3ND.OUT", "w", stdout); int n; cin >>n; vector<long long> a(n); for (int i =0; i <n; i++) { cin >>a[i]; } long long ans =n -1; for(int i=0; i <n;i++) { long long maxgiua =0; for (int j =i +2; j <n; j++) { if (j==i +2) { maxgiua =a[i +1]; } else { maxgiua =max(maxgiua, a[j -1]); } if (max_giua <=min(a[i],a[j])) { ans++; } } } cout <<ans; return 0; }