# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198430 | model_code | W (RMI18_w) | C11 | 59 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* Method: Handles the case of exactly two distinct values.
*
* Author: Catalin Francu
**/
#include <stdio.h>
#define MOD 1000000007
int main() {
int n, x;
int v1, v2 = 0, c1 = 1, c2 = 0;
scanf("%d %d", &n, &v1);
while (--n) {
scanf("%d", &x);
if (x == v1) {
c1++;
} else {
v2 = x;
c2++;
}
}
if (v1 > v2) {
int tmp = c1;
c1 = c2;
c2 = tmp;
}
/**
* Now we know that the smaller value occurs c1 times and the larger value
* occurs c2 times.
**/
int sol = (long long)(c1 - 1) * (c2 - 1) * (c2 - 2) / 2 % MOD;
printf("%d\n", sol);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |