Submission #1169

#TimeUsernameProblemLanguageResultExecution timeMemory
1169kriii고기잡이 (KOI13_fish)C++98
18 / 18
6 ms1188 KiB
#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; }
#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...