제출 #1272044

#제출 시각아이디문제언어결과실행 시간메모리
1272044yeulerZemljište (COCI22_zemljiste)C++20
0 / 70
0 ms332 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define fi first #define se second #define akeh int tc = 1; cin >> tc; while(tc--){solve();} #define vector2d(x) vector<vector<x>> #define pii pair<int, int> #define pl pair<ll, ll> #define kagamine_len ios_base::sync_with_stdio(0); cin.tie(0); #define file_in freopen("input.txt", "r", stdin); #define file_out freopen("output.txt", "w", stdout); #define all(x) x.begin(), x.end() using namespace std; int main(){ kagamine_len // file_in file_out ll r, s, a, b; cin >> r >> s >> a >> b; vector2d(ll) ar(r+1, vector<ll>(s+1)); vector2d(ll) pf(r+1, vector<ll>(s+1, 0)); for (ll i = 1; i <= r; i++){ for (ll j = 1; j <= s; j++){ cin >> ar[i][j]; pf[i][j] = ar[i][j]; pf[i][j] += pf[i-1][j] + pf[i][j-1] - pf[i-1][j-1]; } } ll ans = LLONG_MAX; for (ll i = 1; i <= r; i++){ for (ll j = 1; j <= s; j++){ for (ll k = i; k <= r; k++){ for (ll m = j; m <= s; m++){ ll hg = pf[k][m]-pf[i-1][j]-pf[i][j-1]+pf[i-1][j-1]; ans = min(ans, abs(hg-a)+abs(hg-b)); } } } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...