Submission #799258

#TimeUsernameProblemLanguageResultExecution timeMemory
799258elotelo966Zemljište (COCI22_zemljiste)C++17
30 / 70
2049 ms6564 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define OYY 1000000005 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define mid (start+end)/2 #define mod 1000000007 int pre[505][505],dizi[505][505]; int32_t main(){ faster int n,m,a,b; cin>>n>>m>>a>>b; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>dizi[i][j]; pre[i][j]=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]+dizi[i][j]; } } //////////////DEBUG /*for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cout<<pre[i][j]<<" "; } cout<<endl; }*/ int mini=OYY; for(int i=1;i<=n;i++){ for(int j=i;j<=n;j++){ for(int o=1;o<=m;o++){ for(int p=o;p<=m;p++){ int deg=pre[j][p]-pre[i-1][p]-pre[j][o-1]+pre[i-1][o-1]; //cout<<pre[j][p]<<" "<<pre[i-1][p]<<" "<<pre[j][o-1]<<" "<<pre[i-1][o-1]<<endl; deg=abs(deg-a)+abs(deg-b); mini=min(mini,deg); } } } } cout<<mini<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...