題目連結: https://codeforces.com/problemset/problem/1380/A
# 內容
給你一串數列,尋找符合條件的:
或說 沒有找到
# 思路
如果有解答案必不為遞增或遞減數列,因此一定會存在相鄰的元素滿足
# 程式碼
#include <bits/stdc++.h> | |
using namespace std; | |
const int N = 1000; | |
int n; | |
int a[N]; | |
void solve() { | |
cin >> n; | |
for (int i = 0; i < n; ++i) | |
cin >> a[i]; | |
for (int i = 1; i < n - 1; ++i) { | |
if (a[i] > a[i - 1] && a[i] > a[i + 1]) { | |
cout << "YES" << endl; | |
cout << i << ' ' << i + 1 << ' ' << i + 2 << endl; | |
return; | |
} | |
} | |
cout << "NO" << endl; | |
} | |
int main() { | |
int T; | |
cin >> T; | |
while (T--) | |
} |