조금 생각해보니 전부 같지 않다면 반드시 대장 피라냐가 생긴다! 대장 피라냐는 가장 큰 사이즈일테니 처음에 가장 큰 피라냐를 찾았다. 하지만 틀림ㅎㅎ 알고보니 554일 경우 옆에 작은 값이 있는 가장 큰 값을 찾아야 한다. 그래야 먹고 커지지.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;
void solve()
{
int n;
scanf("%d", &n);
vector<int> v(n);
for (int i = 0; i < n; i++)
scanf("%d", &v[i]);
bool same = true;
for (int i = 1; i < n; i++)
if (v[i] != v[i - 1])
same = false;
if (same)
{
printf("-1\n");
return;
}
int maxidx = 0;
for (int i = 0; i < n; i++)
{
if (i == 0)
{
if (v[i] >= v[maxidx] && v[i] > v[i + 1])
maxidx = i;
continue;
}
if (i == n-1)
{
if (v[i] >= v[maxidx] && v[i] > v[i - 1])
maxidx = i;
continue;
}
if (v[i] >= v[maxidx] && (v[i] > v[i - 1] || v[i] > v[i + 1]))
maxidx = i;
}
printf("%d\n", maxidx + 1);
}
int main()
{
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++)
{
solve();
}
}
'코드포스' 카테고리의 다른 글
[코드포스 Round 677] E. Two Round Dances (0) | 2020.11.07 |
---|---|
[코드포스 Round 677] D. Districts Connection (0) | 2020.11.07 |
[코드포스 Round 677] B. Yet Another Bookshelf (0) | 2020.11.07 |
[코드포스 Round 677] A. Boring Apartments (0) | 2020.11.07 |
[코드포스 Round 677] 후기 (0) | 2020.11.07 |