이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void openFiles() {
#ifdef KEK
assert(freopen("input.txt", "r", stdin));
assert(freopen("output.txt", "w", stdout));
#endif
}
void IOoptimize() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const ll INF = 1e12 + 10;
const int MAXN = 300;
const int MAX = 40;
ll x[MAXN], y[MAXN];
int main() {
openFiles();
IOoptimize();
ll r, c;
cin >> r >> c;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
x[i]--;
y[i]--;
}
ll ans = INF;
for (ll up = 0; up <= r; up++)
for (ll dn = 0; dn <= r; dn++) {
//cout << up << " " << dn << "\n";
ll we = 0;
ll w = 0;
ll e = 0;
for (int i = 0; i < r; i++) {
vector<ll> pos;
for (int j = 0; j < n; j++) {
if (x[j] - up <= i && i <= x[j] + dn)
pos.push_back(y[j]);
}
if (pos.size() == 0) {
we = INF;
}
else {
sort(pos.begin(), pos.end());
for (int j = 1; j < pos.size(); j++) {
we = max(we, pos[j] - pos[j - 1] - 1);
}
w = max(w, pos[0]);
e = max(e, c - pos.back() - 1);
}
}
//cout << w << " " << e << " " << we << "\n";
we = max(we, w + e);
//cout << we << "\n";
ans = min(ans, up + dn + we);
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
cultivation.cpp: In function 'int main()':
cultivation.cpp:54:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 1; j < pos.size(); j++) {
~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |