This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Author: RufatM
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e9+7
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define pb push_back
#define pii pair<ll,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll solve(int n, vector<int>& teams) {
ll day = 0;
int max_team = *max_element(all(teams));
for(int i = 0; i < n; i++) {
for(int j = 1; j < teams[i]; j++) {
vector<int> used(max_team + 2);
for(int k = 0; k < i; k++) {
used[teams[k]] = 1;
}
used[j] = 1;
ll cnt = 1;
int avail = max_team + (j > max_team);
for(int k = i + 1; k < n; k++) {
cnt = (cnt * avail) % MOD;
}
day = (day + cnt) % MOD;
}
if(teams[i] > max_team) break;
}
return (day + 1) % MOD;
}
signed main() {
fastio;
int n;
cin >> n;
vector<int> teams(n);
for(int i = 0; i < n; i++) {
cin >> teams[i];
}
cout << solve(n, teams) << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |