답안 #1071209

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071209 2024-08-23T05:56:58 Z 정민찬(#11138) Cultivation (JOI17_cultivation) C++17
0 / 100
2 ms 600 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf = 2e18;

ll R, C;
ll N;

ll solve(vector<pll> p, ll H1, ll H2) {
	vector<vector<ll>> cur(R+1);
	for (ll i=0; i<N; i++) {
		for (ll j=max(1LL, p[i].first - H1); j<=min(R, p[i].first + H2); j++) {
			cur[j].push_back(p[i].second);
		}
	}
	ll l = 0, r = 0, sum = 0;
	for (ll i=1; i<=R; i++) {
		if (cur[i].empty()) return inf;
		sort(cur[i].begin(), cur[i].end());
		l = max(l, cur[i][0] - 1);
		r = max(r, C - cur[i].back());
		for (ll j=0; j+1<cur[i].size(); j++) {
			sum = max(sum, cur[i][j+1] - cur[i][j]);
		}
	}
	return max(l+r, sum);
}

int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL);
    cin >> R >> C;
    cin >> N;
    vector<pll> p(N);
    for (ll i=0; i<N; i++) {
    	cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());
    ll ans = inf;
    for (ll i=0; i<=R-1; i++) {
    	for (ll j=0; j<=R-1; j++) {
    		ans = min(ans, i + j + solve(p, i, j));
    	}
    }
    cout << ans << '\n';
}

Compilation message

cultivation.cpp: In function 'll solve(std::vector<std::pair<long long int, long long int> >, ll, ll)':
cultivation.cpp:26:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (ll j=0; j+1<cur[i].size(); j++) {
      |                ~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -