#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
long long v[2][2000];
long long w[2];
int main()
{
int n,l;
cin>>n>>l;
for(int i = 0;i<n;i++)
{
for(int j = 0;j<l;j++)
{
cin>>v[i][j];
w[i]+=v[i][j];
}
}
long long s = 0;
int d = -1;
for(int i = 0;i<l;i++)
{
s += v[0][i];
if(s*2 >= w[0])
{
d = i;
s-=v[0][i];
break;
}
}
if(d != -1)
{
pair<long long,long long> x = {w[0]-s*2,v[0][d]*2};
pair<long long,long long> nx = {x.nd-x.st,x.nd};
s = 0;
for(int i = l-1;i>d;i--)
{
s+= v[1][i];
}
if(s*2 + nx.first*v[1][d]*2/nx.nd >= w[1])
{
cout<<x.st + x.nd *d<<" "<<x.nd<<"\n";
cout<<1<<" "<<2<<"\n";
return 0;
}
}
s = 0;
d = -1;
for(int i = 0;i<l;i++)
{
s += v[1][i];
if(s*2 >= w[1])
{
d = i;
s-=v[1][i];
break;
}
}
if(d != -1)
{
pair<long long,long long> x = {w[1]-s*2,v[1][d]*2};
pair<long long,long long> nx = {x.nd-x.st,x.nd};
s = 0;
for(int i = l-1;i>d;i--)
{
s+= v[0][i];
}
if(s*2 + nx.first*v[0][d]*2/nx.nd >= w[0])
{
cout<<x.st + x.nd*d<<" "<<x.nd<<"\n";
cout<<2<<" "<<1<<"\n";
return 0;
}
}
cout<<-1<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |