답안 #307474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307474 2020-09-28T08:56:41 Z keta_tsimakuridze Lottery (CEOI18_lot) C++14
0 / 100
6 ms 1536 KB
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 1e4+5;
int n , l , q , a[N] , b[N] , cur , ans[105][N]  , aft[N],ind[105];
pair< int , int > p[105];
int main() {
	cin>>n>>l;
	for(int k=1; k<=n; k++)
		cin>>a[k];
	cin>>q;
	for(int k=1; k<=q; k++) {
		cin>>p[k].f;
		p[k].s=k;
	}
	//k___l
	// k-ze meti an toli
	sort(p+1,p+q+1);
	cur=1;
	for(int k=0; k<=n; k++){
		while(p[cur].f<k && cur<=q) {
			cur++;
		}
		aft[k]=cur;
	//	cout<<k<<" "<<cur<<endl;
	}

	for(int d=1; d<=n; d++) {
		for(int k=1; k<=n-d; k++) {
			b[k]=0;
			if(a[k]!=a[k+d]){
				b[k]=1;
			}
		}
		//cout<<d<<"___"<<endl;
		for(int k=1; k<=n-d; k++){
			
		//	cout<<b[k]<<" ";
			b[k]+=b[k-1];
			if( k>=l ){
				int K=b[k]-b[k-l];
				ans[k-l+1][aft[K]]++;
				ans[k+d-l+1][aft[K]]++;
			}
		}
	}
	/*
	for(int k=1; k<=n; k++){
		for(int i=1; i<=n; i++){
			cout<<ans[i][k]<<" ";
		}
		cout<<endl;
	}
	*/
	for(int k=1; k<=q; k++){
		ind[p[k].s]=k;
		for(int i=1; i<=n-l+1; i++){
			ans[i][k]=ans[i][k]+ans[i][k-1];
		}
	}
	
	for(int k=1; k<=q; k++){
	
		for(int i=1; i<=n-l+1; i++){
			cout<<ans[i][ind[k]]<<" ";
		}
		cout<<endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 640 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 640 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 640 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Halted 0 ms 0 KB -