답안 #639316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639316 2022-09-09T11:59:46 Z LucaLucaM Maxcomp (info1cup18_maxcomp) C++17
60 / 100
500 ms 20696 KB
#include <bits/stdc++.h>
 
using namespace std;
 
struct cell
{
    int x, i, j;
};
 
bool operator < (const cell a, const cell b)
{
    return a.x < b.x;
}
 
cell a[1000001];
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
 
    int N = 0;
 
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            int x;
            cin >> x;
 
            a[++N].x = x;
            a[N].i = i, a[N].j = j;
        }
    }
 
    sort (a+1, a+N+1);
 
    int M = N/2 + 1;
    int ans = -1;
 
    for (int i=1; i<M; i++)
    {
        for (int j=N; j>=M; j--)
        {
            int d = abs(a[i].i - a[j].i) + abs(a[i].j - a[j].j) + 1;
            int s = a[j].x - a[i].x;
            
            if (s <= ans)
                break;
            ans = max(ans, s - d);
        }
    }
 
    cout << ans;
 
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 172 ms 12044 KB Output is correct
19 Correct 172 ms 20556 KB Output is correct
20 Correct 161 ms 19532 KB Output is correct
21 Correct 180 ms 20572 KB Output is correct
22 Correct 173 ms 20696 KB Output is correct
23 Correct 175 ms 20512 KB Output is correct
24 Execution timed out 1063 ms 20652 KB Time limit exceeded
25 Halted 0 ms 0 KB -