-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2111c.cpp
More file actions
34 lines (31 loc) · 783 Bytes
/
2111c.cpp
File metadata and controls
34 lines (31 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <bits/stdc++.h>
using namespace std;
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define F first
#define S second
#define cases int _; cin >> _; while(_--)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef set<int> si;
void solve() {
ll a; cin >> a; vi A(a); ll minScore = LLONG_MAX;
for(ll i = 0; i < a; i++) cin >> A[i];
for(ll i = 0; i < a; i++) {
ll ogpos = i;
while(i < a-1 && A[i] == A[i+1]) {
i++;
}
minScore = min((a-(i-ogpos)-1)*A[i], minScore);
}
if(count(A.begin(), A.end(), A[0]) == a) {cout << 0 << endl; return;}
cout << minScore << '\n'; return;
}
int main() {
cases {
solve();
}
return 0;
}