답안 #1169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1169 2013-06-28T13:45:00 Z kriii 고기잡이 (KOI13_fish) C++
18 / 18
6 ms 1188 KB
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> X[10010];
int N,L,M,C[10010],Y[101],A;

int main()
{
	int i,j,k,x,y,s;

	scanf ("%d %d %d",&N,&L,&M); L /= 2;
	for (i=0;i<M;i++){
		scanf ("%d %d",&x,&y);
		X[x].push_back(y);
		Y[i] = y;
	}
	sort(Y,Y+M); M = unique(Y,Y+M) - Y;

	for (x=1;x<L;x++){
		y = L - x;

		for (i=1;i<=N;i++) C[i] = 0;
		for (i=1;i<=N;i++){
			for (j=0;j<X[i].size();j++) C[X[i][j]]++;
			if (i - x > 1) for (j=0;j<X[i-x-1].size();j++) C[X[i-x-1][j]]--;

			if (!X[i].empty() || !X[i-x].empty()){
				s = 0;
				for (j=k=0;k<M;k++){
					s += C[Y[k]];
					while (Y[k] - Y[j] > y){
						s -= C[Y[j]]; j++;
					}
					if (A < s)
						A = s;
				}
			}
		}
	}

	printf ("%d",A);

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1188 KB Output is correct
2 Correct 0 ms 1188 KB Output is correct
3 Correct 0 ms 1188 KB Output is correct
4 Correct 0 ms 1188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1188 KB Output is correct
2 Correct 0 ms 1188 KB Output is correct
3 Correct 0 ms 1188 KB Output is correct
4 Correct 0 ms 1188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1188 KB Output is correct
2 Correct 0 ms 1188 KB Output is correct
3 Correct 0 ms 1188 KB Output is correct
4 Correct 1 ms 1188 KB Output is correct
5 Correct 0 ms 1188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1188 KB Output is correct
2 Correct 1 ms 1188 KB Output is correct
3 Correct 1 ms 1188 KB Output is correct
4 Correct 2 ms 1188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1188 KB Output is correct
2 Correct 3 ms 1188 KB Output is correct
3 Correct 5 ms 1188 KB Output is correct
4 Correct 6 ms 1188 KB Output is correct