Untitled
unknown
plain_text
3 years ago
692 B
4
Indexable
#include <iostream> using namespace std; int main() { // Nhap n int n; do{ cin >> n; } while (n < 1 || n > 1000000); // Nhap gia co phieu int a[n]; for (int i = 0; i < n; i++){ cin >> a[i]; } // int b[n]; for (int i = 0; i < n; i++){ b[i] = 1; } for (int i = n - 1; i > 0; i--){ if (a[i] >= a[i-1]){ b[i-1] = b[i] + 1; } } int max = b[0]; int count = 0; for (int i = 1; i < n; i++){ if (max < b[i]) { max = b[i]; } } for (int i = 0; i < n; i++){ if (b[i] == max){ for (int j = i; j < max; j++){ count++; } } } cout << count; return 0; }
Editor is loading...