답안 #1022501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022501 2024-07-13T15:32:40 Z vjudge1 Lottery (CEOI18_lot) C++17
0 / 100
102 ms 848 KB
// 23 - 12 - 23 

#include<bits/stdc++.h>

using namespace std;

#define read() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define day() time_t now = time(0);char* x = ctime(&now);cerr<<"Right Now Is : "<<x<<"\n"

#define ii pair<int,int>
#define X first
#define Y second 

const long long MAX = (int)1e4 + 5;
const long long INF = (int)1e9;
const long long MOD = (int)1e9 + 7;

int n,l,q,a[MAX];
int qrx[MAX];
bool idx[MAX];
int nxt[MAX];
int ans[MAX][105];

signed main(){
	
	read();
	
	cin >> n >> l;
	
	for(int i = 1;i <= n;i++)cin >> a[i];
	
	cin >> q;
	
	vector<int> rt;
	
	for(int i = 1;i <= q;i++){
		cin >> qrx[i];		
		idx[qrx[i]] = 1;
		rt.push_back(qrx[i]);
	}
	
	sort(rt.begin(),rt.end());
	rt.erase(unique(rt.begin(),rt.end()),rt.end());
	
	int k = rt.size() + 1;
	
	for(int i = n;i >= 1;i--){
		if(idx[i])k--;
		nxt[i] = k;
	}
	
	
	vector<int> f(n + 5,0);
	for(int len = 1;len <= n;len++){
		for(int i = 1;i <= n;i++)
			f[i] = f[i - 1] + (a[i] != a[i + len]);
		for(int i = 1;i + l - 1 <= n;i++){
			if(i + len + l - 1 > n)break;
			int cost = nxt[f[i + l - 1] - f[i - 1]];
			ans[cost][i]++;
			ans[cost][i + len]++;
		}
	}
	
	for(int i = 1;i <= (int)rt.size();i++){
		for(int j = 1;j <= n;j++){
			ans[i][j] += ans[i - 1][j];
		}
	}
	
	for(int i = 1;i <= q;i++){
		int x = lower_bound(rt.begin(),rt.end(),qrx[i]) - rt.begin() + 1;
		for(int j = 1;j <= n - l + 1;j++)cout << ans[x][j] << " \n"[j == n - l + 1];
	}
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 102 ms 848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 102 ms 848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -