# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
857479 |
2023-10-06T09:10:09 Z |
lbadea1000 |
W (RMI18_w) |
C++17 |
|
86 ms |
3548 KB |
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 3e5 + 5;
const int MOD = 1e9 + 7;
int v[NMAX];
int main() {
int n;
cin >> n;
for(int i = 0; i < n; i++)
cin >> v[i];
sort(v, v + n);
int cnt1 = 0;
int i = 0;
while(i < n && v[i] == v[0]) {
i++;
cnt1++;
}
int cnt2 = 0;
while(i < n && v[i] == v[n - 1]) {
i++;
cnt2++;
}
if(cnt1 + cnt2 == n)
cout << 1LL * (cnt2 - 2) * (cnt2 - 1) / 2 % MOD * (cnt1 - 1) % MOD;
else {
int ans = 0;
for(int a = 2; a <= n - 3; a++) {
ans = (ans + (1LL * (n - a - 2) * (n - a - 1) / 2 % MOD)) % MOD;
}
cout << ans;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
11 ms |
820 KB |
Output is correct |
4 |
Correct |
46 ms |
2472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
360 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
8 ms |
688 KB |
Output isn't correct |
4 |
Incorrect |
29 ms |
1488 KB |
Output isn't correct |
5 |
Incorrect |
62 ms |
2560 KB |
Output isn't correct |
6 |
Incorrect |
86 ms |
3492 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
456 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
360 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
360 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
360 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
360 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
360 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
360 KB |
Output isn't correct |
8 |
Incorrect |
28 ms |
1384 KB |
Output isn't correct |
9 |
Incorrect |
43 ms |
2132 KB |
Output isn't correct |
10 |
Incorrect |
84 ms |
3548 KB |
Output isn't correct |