Submission #445936

# Submission time Handle Problem Language Result Execution time Memory
445936 2021-07-20T08:23:27 Z snasibov05 Nuclearia (CEOI15_nuclearia) C++14
0 / 100
1000 ms 276428 KB
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

#define int long long
#define pii pair<int, int>
#define f first
#define s second
#define oo 1000000000

signed main() {
    int w, h; cin >> w >> h;
    int n; cin >> n;
    vector<vector<int>> rad(w+1, vector<int>(h+1));
    for (int i = 0; i < n; ++i) {
        int x, y, a, b; cin >> x >> y >> a >> b;

        for (int j = 1; j <= w; ++j) {
            for (int k = 1; k <= h; ++k) {
                rad[j][k] += 1ll * max(0ll, a - b * max(abs(j - x), abs(k - y)));
            }
        }
    }

    vector<vector<int>> pref(w+1, vector<int>(h+1));
    for (int i = 1; i <= w; ++i) {
        for (int j = 1; j <= h; ++j) {
            pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + rad[i][j];
        }
    }

    int q; cin >> q;
    for (int i = 0; i < q; ++i) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        int cur = pref[x2][y2] - pref[x2][y1 - 1] - pref[x1 - 1][y2] + pref[x1 - 1][y1 - 1];
        int cnt = (x2 - x1 + 1) * (y2 - y1 + 1);
        //cerr << cur << " " << cnt << "\n";
        int res = cur / cnt;

        if (cur % cnt >= (int)ceil(cnt / 2)) res++;

        cout << res << "\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 848 ms 274224 KB Output is correct
2 Incorrect 488 ms 2604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 823 ms 274224 KB Output is correct
2 Incorrect 487 ms 2620 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 290 ms 39756 KB Output is correct
2 Incorrect 478 ms 2652 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 279 ms 42408 KB Output is correct
2 Incorrect 490 ms 2768 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 276428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 111720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 868 ms 41924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 57580 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 137188 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 137272 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 20044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 19916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 20556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 20044 KB Time limit exceeded
2 Halted 0 ms 0 KB -