Submission #1170150

#TimeUsernameProblemLanguageResultExecution timeMemory
1170150Szymon_PilipczukNaan (JOI19_naan)C++20
0 / 100
1 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
int 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<int,int> x = {w[0]-s*2,v[0][d]*2};
        pair<int,int> 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<int,int> x = {w[1]-s*2,v[1][d]*2};
        pair<int,int> 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...