Submission #197363

# Submission time Handle Problem Language Result Execution time Memory
197363 2020-01-20T14:49:32 Z kmekhovich Maxcomp (info1cup18_maxcomp) C++14
0 / 100
3 ms 504 KB
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define pb push_back
#define fst first
#define snd second
#define all(c) (c).begin(), (c).end()
typedef long long ll;
typedef long double ld;
const ll INF64 = 1e18 + 228;
const int INF32 = 1e9 + 1337;
const int MOD = 1e9 + 7;
const ld eps = 1e-7;
const int N = 1e3 + 3;
signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef __WIN32
    ifstream cin("input.txt");
    ofstream cout("output.txt");
#endif

    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll> > a(n * m);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        {
            ll x;
            cin >> x;
            a[i * m + j] = {x + i + j + 1, i + j + 1};
        }
    sort(all(a));
//    for(auto& it : a)
//        cout << it.fst << " " << it.snd << "\n";
//    cout << "\n";
    cout << a.back().fst - a[0].fst - 2 * abs(a.back().snd - a[0].snd) - 1;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -