답안 #950676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950676 2024-03-20T14:56:40 Z Irate 과수원 (NOI14_orchard) C++14
16 / 25
1000 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;
const int mxN = 155;
const int mxM = 1e6 + 5;
int grid[mxN][mxM], pref[mxN][mxM];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1;i <= n;++i){
        for(int j = 1;j <= m;++j){
            cin >> grid[i][j];
            pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + grid[i][j];
        }
    }
    int mn = 1e9;
    for(int k = 1;k <= n;++k){
        for(int i = 1;i + k - 1 <= n;++i){
            set<int>s;
            s.insert(-1);
            for(int j = 1;j <= m;++j){
                auto itr = s.begin();
                int sum = pref[i + k - 1][j] - pref[i - 1][j];
                mn = min(mn, j * k - 2 * sum + pref[n][m] + k + *itr);
                s.insert(2 * (pref[i + k - 1][j] - pref[i - 1][j]) - k * (j + 1));
            }
        }
    }
    cout << mn << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 2 ms 2600 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 11112 KB Output is correct
2 Correct 71 ms 11068 KB Output is correct
3 Correct 74 ms 11088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 7256 KB Output is correct
2 Correct 18 ms 7768 KB Output is correct
3 Correct 18 ms 7772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 206396 KB Output is correct
2 Runtime error 59 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1065 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -