#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "
#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back
const int mod = 1e9 + 7;
ll add(ll x, ll y) {
return (x % mod + y % mod) % mod;
}
ll factorial(ll n) {
ll res = 1;
while(n) {
res *= n;
res %= mod;
--n;
}
return (res % mod);
}
void solve()
{
ll n;
cin >> n;
vi a(n);
FOR(i, 0, n)
cin >> a[i];
bool increasing = true;
FOR(i, 1, n) {
if(a[i] < a[i - 1]) {
increasing = false;
break;
}
}
ll ans = 0;
if(increasing) {
ans = 1;
} else {
ans = factorial(n);
}
cout << ans << nl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t = 1;
// cin >> t;
while (t--)
{
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
28 ms |
2644 KB |
Output is correct |
3 |
Correct |
31 ms |
5472 KB |
Output is correct |
4 |
Correct |
33 ms |
5452 KB |
Output is correct |
5 |
Correct |
31 ms |
5472 KB |
Output is correct |
6 |
Correct |
34 ms |
5468 KB |
Output is correct |
7 |
Correct |
28 ms |
5464 KB |
Output is correct |
8 |
Correct |
30 ms |
5460 KB |
Output is correct |
9 |
Correct |
30 ms |
5472 KB |
Output is correct |
10 |
Correct |
31 ms |
5460 KB |
Output is correct |
11 |
Correct |
30 ms |
5476 KB |
Output is correct |
12 |
Correct |
30 ms |
5460 KB |
Output is correct |
13 |
Correct |
29 ms |
5460 KB |
Output is correct |
14 |
Correct |
31 ms |
5452 KB |
Output is correct |
15 |
Correct |
28 ms |
5468 KB |
Output is correct |
16 |
Correct |
29 ms |
5556 KB |
Output is correct |
17 |
Correct |
28 ms |
5476 KB |
Output is correct |
18 |
Correct |
28 ms |
5456 KB |
Output is correct |
19 |
Correct |
29 ms |
5476 KB |
Output is correct |
20 |
Correct |
30 ms |
5472 KB |
Output is correct |
21 |
Correct |
34 ms |
5476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
23 ms |
2644 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
23 ms |
2644 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |