#include <bits/stdc++.h>
using namespace std;
#define ll long long
//14:20
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int h,w,n,q;
cin >> w >> h >> n;
vector<pair<pair<int,int>,pair<ll,ll> > > plant(n);
for(int i = 0; i < n; i++) {
cin >> plant[i].first.first >> plant[i].first.second >> plant[i].second.first >> plant[i].second.second;
}
vector<vector<ll> > table(w+2,vector<ll>(h+2,0));
for(int i = 1; i <= w; i++) {
for(int j = 1; j <= h; j++) {
for(int p = 0; p < n; p++) {
table[i][j]+= max(0LL,plant[p].second.first-plant[p].second.second*(max(abs(i-plant[p].first.first),abs(j-plant[p].first.second))));
}
}
}
//vector<vector<ll> > table(h+2,vector<ll>(w+2));
cin >> q;
while(q--) {
int x1,x2,y1,y2;
cin >> x1 >> y1 >> x2 >> y2;
ll ans = 0;
for(int i = x1; i <= x2; i++) {
for(int j = y1; j <= y2; j++) {
ans+= table[i][j];
}
}
int are = (y2-y1+1)*(x2-x1+1);
int an = ans/are;
if(ans-an*are >= (an+1)*are-ans) {
an++;
}
cout << an << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
906 ms |
137308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
888 ms |
137520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
503 ms |
137520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
466 ms |
137520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
137688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
137688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1049 ms |
137688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
137688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
146448 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1106 ms |
150276 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1053 ms |
150276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1079 ms |
150276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
150276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
150276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |