제출 #936962

#제출 시각아이디문제언어결과실행 시간메모리
936962089487Zemljište (COCI22_zemljiste)C++14
30 / 70
2058 ms4820 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("sse4,abm,avx,popcnt") #include<bits/stdc++.h> #define int long long #define quick ios::sync_with_stdio(0);cin.tie(0); #define rep(x,a,b) for(int x=a;x<=b;x++) #define repd(x,a,b) for(int x=a;x>=b;x--) #define F first #define S second #define eb emplace_back #define mp make_pair #define mt make_tuple #define all(x) x.begin(),x.end() #define sz(x) (int)(x.size()) #define lowbit(x) (x&-x) using namespace std; typedef pair<int,int> pii; void debug(){ cout<<"\n"; } template<class T,class ...U> void debug(T a,U ...b){ cout<<a<<" ",debug(b...); } const int N=5e2+7; const int INF=1e18L; int c[N][N]; signed main(){ quick int r,s,a,b; cin>>r>>s>>a>>b; rep(i,1,r){ rep(j,1,s){ cin>>c[i][j]; c[i][j]+=c[i-1][j]+c[i][j-1]-c[i-1][j-1]; } } int ans=INF; rep(x1,1,r){ rep(x2,x1,r){ rep(y1,1,s){ rep(y2,y1,s){ int S=c[x2][y2]-c[x1-1][y2]-c[x2][y1-1]+c[x1-1][y1-1]; ans=min(ans,abs(S-a)+abs(S-b)); } } } } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...