Submission #674144

# Submission time Handle Problem Language Result Execution time Memory
674144 2022-12-23T10:25:50 Z QwertyPi The grade (info1cup18_thegrade) C++14
100 / 100
229 ms 11164 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;

const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 11;
int pm(int a, int b){
	return b == 0 ? 1 : pm(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD;
}

int mi(int a){
	return pm(a, MOD - 2);
}

map<int, int> M; int s = 0;
int f[MAXN];

int32_t main(){
	f[0] = 1; for(int i = 1; i < MAXN; i++) f[i] = f[i - 1] * i % MOD;
	int q, e; cin >> q >> e; int k = 0;
	int mul = 1;
	for(int i = 0; i < q; i++){
		int t, v; cin >> t >> v;
		if(t == 0){
			M[v]++; s++; e -= v;
			mul = mul * mi(M[v]) % MOD;
		}else{
			mul = mul * M[v] % MOD;
			M[v]--; s--; e += v;
		}
		if(e < 0){
			cout << -1 << endl;
		}else{
			cout << f[s + e] * mul % MOD * mi(f[e]) % MOD << endl;
		}
	}
}

Compilation message

thegrade.cpp: In function 'int32_t main()':
thegrade.cpp:22:31: warning: unused variable 'k' [-Wunused-variable]
   22 |  int q, e; cin >> q >> e; int k = 0;
      |                               ^
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8020 KB Output is correct
2 Correct 11 ms 8128 KB Output is correct
3 Correct 10 ms 8020 KB Output is correct
4 Correct 10 ms 8128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 8148 KB Output is correct
2 Correct 190 ms 9192 KB Output is correct
3 Correct 199 ms 9676 KB Output is correct
4 Correct 187 ms 9400 KB Output is correct
5 Correct 192 ms 9164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 8204 KB Output is correct
2 Correct 213 ms 9712 KB Output is correct
3 Correct 223 ms 9816 KB Output is correct
4 Correct 208 ms 9648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8020 KB Output is correct
2 Correct 11 ms 8128 KB Output is correct
3 Correct 10 ms 8020 KB Output is correct
4 Correct 10 ms 8128 KB Output is correct
5 Correct 15 ms 8148 KB Output is correct
6 Correct 190 ms 9192 KB Output is correct
7 Correct 199 ms 9676 KB Output is correct
8 Correct 187 ms 9400 KB Output is correct
9 Correct 192 ms 9164 KB Output is correct
10 Correct 16 ms 8204 KB Output is correct
11 Correct 213 ms 9712 KB Output is correct
12 Correct 223 ms 9816 KB Output is correct
13 Correct 208 ms 9648 KB Output is correct
14 Correct 16 ms 8136 KB Output is correct
15 Correct 197 ms 9408 KB Output is correct
16 Correct 195 ms 9420 KB Output is correct
17 Correct 197 ms 9420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 8148 KB Output is correct
2 Correct 190 ms 9192 KB Output is correct
3 Correct 199 ms 9676 KB Output is correct
4 Correct 187 ms 9400 KB Output is correct
5 Correct 192 ms 9164 KB Output is correct
6 Correct 196 ms 9580 KB Output is correct
7 Correct 196 ms 9580 KB Output is correct
8 Correct 196 ms 9612 KB Output is correct
9 Correct 197 ms 9592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 8204 KB Output is correct
2 Correct 213 ms 9712 KB Output is correct
3 Correct 223 ms 9816 KB Output is correct
4 Correct 208 ms 9648 KB Output is correct
5 Correct 197 ms 9584 KB Output is correct
6 Correct 200 ms 9892 KB Output is correct
7 Correct 229 ms 11164 KB Output is correct
8 Correct 193 ms 9380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8020 KB Output is correct
2 Correct 11 ms 8128 KB Output is correct
3 Correct 10 ms 8020 KB Output is correct
4 Correct 10 ms 8128 KB Output is correct
5 Correct 15 ms 8148 KB Output is correct
6 Correct 190 ms 9192 KB Output is correct
7 Correct 199 ms 9676 KB Output is correct
8 Correct 187 ms 9400 KB Output is correct
9 Correct 192 ms 9164 KB Output is correct
10 Correct 16 ms 8204 KB Output is correct
11 Correct 213 ms 9712 KB Output is correct
12 Correct 223 ms 9816 KB Output is correct
13 Correct 208 ms 9648 KB Output is correct
14 Correct 16 ms 8136 KB Output is correct
15 Correct 197 ms 9408 KB Output is correct
16 Correct 195 ms 9420 KB Output is correct
17 Correct 197 ms 9420 KB Output is correct
18 Correct 196 ms 9580 KB Output is correct
19 Correct 196 ms 9580 KB Output is correct
20 Correct 196 ms 9612 KB Output is correct
21 Correct 197 ms 9592 KB Output is correct
22 Correct 197 ms 9584 KB Output is correct
23 Correct 200 ms 9892 KB Output is correct
24 Correct 229 ms 11164 KB Output is correct
25 Correct 193 ms 9380 KB Output is correct
26 Correct 205 ms 9612 KB Output is correct
27 Correct 208 ms 9596 KB Output is correct
28 Correct 201 ms 9532 KB Output is correct
29 Correct 205 ms 9632 KB Output is correct
30 Correct 209 ms 9564 KB Output is correct