Submission #445934

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

using namespace std;

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

int main() {
    int w, h; cin >> w >> h;
    int n; cin >> n;
    vector<vector<ll>> rad(w+1, vector<ll>(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, 1ll * a - 1ll * b * max(abs(j - x), abs(k - y)));
            }
        }
    }

    vector<vector<ll>> pref(w+1, vector<ll>(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;
        ll cur = pref[x2][y2] - pref[x2][y1 - 1] - pref[x1 - 1][y2] + pref[x1 - 1][y1 - 1];
        ll cnt = (x2 - x1 + 1) * (y2 - y1 + 1);
        cerr << cur << " " << cnt << "\n";
        ll res = cur / cnt;

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

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

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 808 ms 274220 KB Output is correct
2 Execution timed out 1086 ms 3752 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 828 ms 274356 KB Output is correct
2 Execution timed out 1075 ms 3776 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 232 ms 39820 KB Output is correct
2 Execution timed out 1085 ms 3904 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 220 ms 42432 KB Output is correct
2 Execution timed out 1090 ms 3756 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1109 ms 276796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 111648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 42900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 57840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 137168 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 137164 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 20044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 19916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 20556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 20008 KB Time limit exceeded
2 Halted 0 ms 0 KB -