#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int MAXN = 2000;
const int MAXL = 2000;
const ld eps = 0.000000000000001;
int v[MAXN][MAXL];
int a, b;
bool rozw1 (int n, int l) {
ld suma0 = 0;
ld suma1 = 0;
for (int i = 0; i < l; i ++) {
suma0 += v[0][i];
suma1 += v[1][i];
}
suma0 /= 2.0;
suma1 /= 2.0;
ld akt = 0;
int ind = -1;
while (ind + 1 < l && ld(v[0][ind + 1]) + akt <= suma0) {
akt += ld(v[0][ind + 1]);
ind ++;
}
ind ++;
suma0 *= 2.0;
ld akt2 = 0;
for (int i = l - 1; i > ind; i --) {
akt2 += v[1][i];
}
akt2 += (1.0 - ld(suma0 - 2.0 * akt)/ ld(2 * v[0][ind])) * v[1][ind];
if (akt2 + eps < suma1) {
return false;
}
cout << suma0 - 2.0 * akt + ind * 2 * v[0][ind] << " " << 2 * v[0][ind] << "\n";
cout << a << " " << b << "\n";
return true;
}
int main () {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, l;
cin >> n >> l;
for (int i = 0; i < n; i ++) {
for (int j = 0; j < l; j ++) {
cin >> v[i][j];
}
}
if (n == 2) {
a = 1, b = 2;
if (!rozw1(n, l)) {
for (int i = 0; i < l; i ++) {
swap(v[0][i], v[1][i]);
}
swap(a, b);
if (!rozw1(n, l)) {
cout << -1 << "\n";
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |