#include <bits/stdc++.h>
#define N 10005
using namespace std;
typedef long long ll;
ll Pow(ll x, ll p)
{
if(!p) return 1LL;
ll ans = Pow(x, p/2);
ans = ans*ans;
if(p & 1) return ans*x;
return ans;
}
ll n, k, v[N], tot, used[N];
ll solve(ll n, ll k)
{
if(n == k) return 1;
if(k > n or k < 0) return 0;
return solve(n - 1, k) * k + solve(n - 1, k - 1);
}
ll pos()
{
//for(ll i = 1; i <= k; i++) tot += solve(n, k);
set<ll> add;
ll q;
for(ll i = 1; i <= n; i++)
{
// tot += solve_suf(n - i, add.size()) * (v[i] - 1);
add.insert(v[i]);
tot += pow(add.size(), n - i)*(v[i] - 1);
}
return tot + 1;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
for(ll i = 1; i <= n; i++)
{
cin>>v[i];
if(!used[v[i]]) k++;
used[v[i]] = 1;
}
cout<<pos()<<"\n";
}
Compilation message
teams.cpp: In function 'll pos()':
teams.cpp:36:5: warning: unused variable 'q' [-Wunused-variable]
ll q;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
440 KB |
Output is correct |
4 |
Correct |
3 ms |
444 KB |
Output is correct |
5 |
Correct |
2 ms |
524 KB |
Output is correct |
6 |
Correct |
3 ms |
524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
568 KB |
Output is correct |
2 |
Incorrect |
2 ms |
568 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
572 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1280 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |