Submission #445937

# Submission time Handle Problem Language Result Execution time Memory
445937 2021-07-20T08:25:53 Z snasibov05 Nuclearia (CEOI15_nuclearia) C++14
20 / 100
1000 ms 276476 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;
        
        int k = cnt / 2;
        if (cnt % 2 == 1) k++;

        if (cur % cnt >= k) res++;

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

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 858 ms 274212 KB Output is correct
2 Correct 549 ms 2672 KB Output is correct
3 Correct 489 ms 3744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 831 ms 274360 KB Output is correct
2 Correct 491 ms 2676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 289 ms 39764 KB Output is correct
2 Correct 491 ms 2708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 284 ms 42404 KB Output is correct
2 Correct 490 ms 2696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 276476 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 111884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 851 ms 41860 KB Output is correct
2 Correct 497 ms 4788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 998 ms 57696 KB Output is correct
2 Correct 483 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 137228 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1104 ms 137260 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 20044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 19892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 20556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 20044 KB Time limit exceeded
2 Halted 0 ms 0 KB -