Submission #62522

#TimeUsernameProblemLanguageResultExecution timeMemory
62522MatheusLealVCalvinball championship (CEOI15_teams)C++17
10 / 100
6 ms1280 KiB
#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 (stderr)

teams.cpp: In function 'll pos()':
teams.cpp:36:5: warning: unused variable 'q' [-Wunused-variable]
  ll q;
     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...