Submission #1090642

# Submission time Handle Problem Language Result Execution time Memory
1090642 2024-09-18T14:50:38 Z Kuzeuy54_ Zemljište (COCI22_zemljiste) C++17
0 / 70
3 ms 4444 KB
#include <bits/stdc++.h>
using namespace std;
#define inf 1e18
#define int long long
const int mod=1e9+7;
const int MAXN=505;
vector<vector<int>>dp(MAXN,vector<int>(MAXN,0));
vector<vector<int>>mat(MAXN,vector<int>(MAXN,0));
int32_t main(){
    int x,y,a,b,temp,temp2,ans=inf;
	cin>>x>>y>>a>>b;
	temp=max(a,b);
	temp2=min(a,b);
	a=temp;
	b=temp2;
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
			cin>>mat[i][j];
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
			dp[i][j]=mat[i][j]+dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
	for(int i=1;i<=x;i++){
		int l=1,r=1;
		while(l<=r&&r<=y){
			int aq=dp[i][r]-dp[0][r]-dp[i][l-1]+dp[0][l-1];
			ans=min(abs(a-aq)+abs(b-aq),ans);
			if(aq<a)
				r++;
			else
				l++;
		}
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -