# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
417240 |
2021-06-03T13:52:07 Z |
egekabas |
Lottery (CEOI18_lot) |
C++14 |
|
1862 ms |
13040 KB |
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, l, q;
int a[10009];
int ans[109][10009];
int k[109];
vector<int> val;
vector<int> st[10009];
ll tot[10009][109];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n >> l;
vector<int> mpp;
for(int i = 0; i < n; ++i)
cin >> a[i];
cin >> q;
for(int i = 0; i < q; ++i){
cin >> k[i];
val.pb(k[i]);
}
sort(all(val));
val.resize(unique(all(val))-val.begin());
for(int dis = 1; dis < n; ++dis){
vector<int> pre(n);
for(int i = 0; i+dis < n; ++i)
if(a[i] == a[i+dis]){
pre[max(0, i-l+1)]++;
pre[i+1]--;
}
for(int i = 0; i < n; ++i){
if(i)
pre[i] += pre[i-1];
if(i+dis+l <= n){
int idx = lower_bound(all(val), l-pre[i])-val.begin();
tot[i][idx]++;
tot[i+dis][idx]++;
}
}
}
for(int i = 0; i < n; ++i)
for(int j = 1; j < val.size(); ++j)
tot[i][j] += tot[i][j-1];
for(int i = 0; i < q; ++i){
ll curval = lower_bound(all(val), k[i])-val.begin();
for(int j = 0; j+l <= n; ++j)
cout << tot[j][curval] << ' ';
cout << '\n';
}
}
Compilation message
lot.cpp: In function 'int main()':
lot.cpp:58:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int j = 1; j < val.size(); ++j)
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
2 ms |
844 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
2 ms |
844 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
716 KB |
Output is correct |
13 |
Correct |
34 ms |
2284 KB |
Output is correct |
14 |
Correct |
24 ms |
2340 KB |
Output is correct |
15 |
Correct |
23 ms |
2248 KB |
Output is correct |
16 |
Correct |
33 ms |
2372 KB |
Output is correct |
17 |
Correct |
31 ms |
2252 KB |
Output is correct |
18 |
Correct |
36 ms |
2244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1022 ms |
9176 KB |
Output is correct |
2 |
Correct |
938 ms |
9168 KB |
Output is correct |
3 |
Correct |
740 ms |
9176 KB |
Output is correct |
4 |
Correct |
675 ms |
9080 KB |
Output is correct |
5 |
Correct |
445 ms |
4988 KB |
Output is correct |
6 |
Correct |
625 ms |
8672 KB |
Output is correct |
7 |
Correct |
467 ms |
4996 KB |
Output is correct |
8 |
Correct |
521 ms |
6692 KB |
Output is correct |
9 |
Correct |
647 ms |
8964 KB |
Output is correct |
10 |
Correct |
667 ms |
9092 KB |
Output is correct |
11 |
Correct |
46 ms |
2228 KB |
Output is correct |
12 |
Correct |
445 ms |
6640 KB |
Output is correct |
13 |
Correct |
444 ms |
5756 KB |
Output is correct |
14 |
Correct |
452 ms |
5764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1022 ms |
9176 KB |
Output is correct |
2 |
Correct |
938 ms |
9168 KB |
Output is correct |
3 |
Correct |
740 ms |
9176 KB |
Output is correct |
4 |
Correct |
675 ms |
9080 KB |
Output is correct |
5 |
Correct |
445 ms |
4988 KB |
Output is correct |
6 |
Correct |
625 ms |
8672 KB |
Output is correct |
7 |
Correct |
467 ms |
4996 KB |
Output is correct |
8 |
Correct |
521 ms |
6692 KB |
Output is correct |
9 |
Correct |
647 ms |
8964 KB |
Output is correct |
10 |
Correct |
667 ms |
9092 KB |
Output is correct |
11 |
Correct |
46 ms |
2228 KB |
Output is correct |
12 |
Correct |
445 ms |
6640 KB |
Output is correct |
13 |
Correct |
444 ms |
5756 KB |
Output is correct |
14 |
Correct |
452 ms |
5764 KB |
Output is correct |
15 |
Correct |
703 ms |
8908 KB |
Output is correct |
16 |
Correct |
610 ms |
8396 KB |
Output is correct |
17 |
Correct |
711 ms |
9248 KB |
Output is correct |
18 |
Correct |
698 ms |
9164 KB |
Output is correct |
19 |
Correct |
687 ms |
9164 KB |
Output is correct |
20 |
Correct |
684 ms |
9284 KB |
Output is correct |
21 |
Correct |
683 ms |
9284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
2 ms |
844 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
716 KB |
Output is correct |
13 |
Correct |
34 ms |
2284 KB |
Output is correct |
14 |
Correct |
24 ms |
2340 KB |
Output is correct |
15 |
Correct |
23 ms |
2248 KB |
Output is correct |
16 |
Correct |
33 ms |
2372 KB |
Output is correct |
17 |
Correct |
31 ms |
2252 KB |
Output is correct |
18 |
Correct |
36 ms |
2244 KB |
Output is correct |
19 |
Correct |
1022 ms |
9176 KB |
Output is correct |
20 |
Correct |
938 ms |
9168 KB |
Output is correct |
21 |
Correct |
740 ms |
9176 KB |
Output is correct |
22 |
Correct |
675 ms |
9080 KB |
Output is correct |
23 |
Correct |
445 ms |
4988 KB |
Output is correct |
24 |
Correct |
625 ms |
8672 KB |
Output is correct |
25 |
Correct |
467 ms |
4996 KB |
Output is correct |
26 |
Correct |
521 ms |
6692 KB |
Output is correct |
27 |
Correct |
647 ms |
8964 KB |
Output is correct |
28 |
Correct |
667 ms |
9092 KB |
Output is correct |
29 |
Correct |
46 ms |
2228 KB |
Output is correct |
30 |
Correct |
445 ms |
6640 KB |
Output is correct |
31 |
Correct |
444 ms |
5756 KB |
Output is correct |
32 |
Correct |
452 ms |
5764 KB |
Output is correct |
33 |
Correct |
703 ms |
8908 KB |
Output is correct |
34 |
Correct |
610 ms |
8396 KB |
Output is correct |
35 |
Correct |
711 ms |
9248 KB |
Output is correct |
36 |
Correct |
698 ms |
9164 KB |
Output is correct |
37 |
Correct |
687 ms |
9164 KB |
Output is correct |
38 |
Correct |
684 ms |
9284 KB |
Output is correct |
39 |
Correct |
683 ms |
9284 KB |
Output is correct |
40 |
Correct |
1212 ms |
9984 KB |
Output is correct |
41 |
Correct |
350 ms |
9284 KB |
Output is correct |
42 |
Correct |
843 ms |
9960 KB |
Output is correct |
43 |
Correct |
783 ms |
9652 KB |
Output is correct |
44 |
Correct |
788 ms |
9768 KB |
Output is correct |
45 |
Correct |
1862 ms |
12928 KB |
Output is correct |
46 |
Correct |
360 ms |
9540 KB |
Output is correct |
47 |
Correct |
1050 ms |
13040 KB |
Output is correct |
48 |
Correct |
988 ms |
11304 KB |
Output is correct |
49 |
Correct |
979 ms |
12012 KB |
Output is correct |