Submission #1071363

#TimeUsernameProblemLanguageResultExecution timeMemory
107136312345678Cultivation (JOI17_cultivation)C++17
30 / 100
284 ms780 KiB
#include <bits/stdc++.h> using namespace std; const int nx=305; int r, c, n, a[nx], b[nx], res=INT_MAX; vector<int> d[nx]; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>r>>c>>n; for (int i=1; i<=n; i++) cin>>a[i]>>b[i]; for (int up=0; up<r; up++) { for (int dn=0; dn<r; dn++) { for (int i=1; i<=r; i++) d[i].clear(); int x=0, g=0, y=0, f=0; for (int i=1; i<=n; i++) for (int j=max(a[i]-up, 1); j<=min(r, a[i]+dn); j++) d[j].push_back(b[i]); for (int i=1; i<=r; i++) { if (d[i].empty()) { f=1; break; } sort(d[i].begin(), d[i].end()); x=max(x, d[i][0]-1); y=max(y, c-d[i].back()); for (int j=1; j<d[i].size(); j++) g=max(g, d[i][j]-d[i][j-1]-1); } if (f) continue; if (x+y>=g) res=min(res, up+dn+x+y); else res=min(res, up+dn+g); } } cout<<res; }

Compilation message (stderr)

cultivation.cpp: In function 'int main()':
cultivation.cpp:32:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |                 for (int j=1; j<d[i].size(); j++) g=max(g, d[i][j]-d[i][j-1]-1);
      |                               ~^~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...