Submission #417198

#TimeUsernameProblemLanguageResultExecution timeMemory
417198egekabasLottery (CEOI18_lot)C++14
45 / 100
3047 ms1096 KiB
#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> vec[10009]; 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]; mpp.pb(a[i]); } sort(all(mpp)); mpp.resize(unique(all(mpp))-mpp.begin()); for(int i = 0; i < n; ++i){ a[i] = lower_bound(all(mpp), a[i])-mpp.begin(); vec[a[i]].pb(i); } cin >> q; for(int i = 0; i < q; ++i) cin >> k[i]; for(int i = 0; i+l <= n; ++i){ vector<int> dis(n, l); for(int j = 0; j < l; ++j){ for(auto u : vec[a[i+j]]) if(u-j >= 0) dis[u-j]--; } vector<int> st; for(int j = 0; j+l <= n; ++j) if(i != j) st.pb(dis[j]); sort(all(st)); for(ll j = 0; j < q; ++j) ans[j][i] = upper_bound(all(st), k[j])-st.begin(); } for(int i = 0; i < q; ++i){ for(ll j = 0; j+l <= n; ++j) cout << ans[i][j] << ' '; cout << '\n'; } }
#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...