Submission #587952

# Submission time Handle Problem Language Result Execution time Memory
587952 2022-07-02T14:55:03 Z Blagojce Calvinball championship (CEOI15_teams) C++11
20 / 100
1000 ms 596 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int mxn = 2e5 + 5;
const ll  mod = 1e9 + 7;

int a[mxn];
int n;
	
	
ll C(int N, int K){
	if(N == 0) return 1;
	return C(N-1, K+1) + C(N-1, K)*K;
}
	
int main(){
	cin >> n;
	fr(i, 0, n){
		cin >> a[i];
	}
	
	int nxt = 2;
	ll ans = 1;
	fr(i, 0, n){
		
		int rem = n-i;
	
		ans += (a[i]-1) * C(rem-1, nxt-1);
		if(a[i] == nxt){
			nxt++;
		}
	}
	cout<<ans<<endl;
	
	
	
}



# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -