Submission #130754

# Submission time Handle Problem Language Result Execution time Memory
130754 2019-07-16T04:35:22 Z nandonathaniel Nuclearia (CEOI15_nuclearia) C++14
30 / 100
1000 ms 127864 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAXN=200005;
LL x[MAXN],y[MAXN],a[MAXN],b[MAXN];

LL dist(LL ax,LL ay,LL bx,LL by){
	return max(abs(ax-bx),abs(ay-by));
}

LL ceiling(LL x){
	if(x&1)return x/2+1;
	else return x/2;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	LL r,c,n,q,x1,y1,x2,y2;
	cin >> c >> r >> n;
	LL pref[r+5][c+5];
	memset(pref,0,sizeof(pref));
	for(LL i=1;i<=n;i++)cin >> y[i] >> x[i] >> a[i] >> b[i];
	for(LL i=1;i<=r;i++){
		for(LL j=1;j<=c;j++){
			for(LL k=1;k<=n;k++)pref[i][j]+=max(0LL,a[k]-b[k]*dist(i,j,x[k],y[k]));
		}
	}
	for(LL i=1;i<=r;i++){
		for(LL j=1;j<=c;j++){
			pref[i][j]+=pref[i][j-1]+pref[i-1][j]-pref[i-1][j-1];
		}
	}
	cin >> q;
	while(q--){
		cin >> y1 >> x1 >> y2 >> x2;
		LL bagi=(pref[x2][y2]-pref[x1-1][y2]-pref[x2][y1-1]+pref[x1-1][y1-1])/((x2-x1+1)*(y2-y1+1));
		LL sisa=(pref[x2][y2]-pref[x1-1][y2]-pref[x2][y1-1]+pref[x1-1][y1-1])%((x2-x1+1)*(y2-y1+1));
		if(sisa>=ceiling((x2-x1+1)*(y2-y1+1)))bagi++;
		cout << bagi << '\n';
	}
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 397 ms 117864 KB Output is correct
2 Correct 83 ms 4732 KB Output is correct
3 Correct 76 ms 3940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 399 ms 117880 KB Output is correct
2 Correct 83 ms 4728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 316 ms 20088 KB Output is correct
2 Correct 85 ms 4528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 317 ms 24860 KB Output is correct
2 Correct 86 ms 4720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 312 ms 123640 KB Output is correct
2 Correct 90 ms 5368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 446 ms 53148 KB Output is correct
2 Correct 82 ms 4728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 468 ms 25976 KB Output is correct
2 Correct 87 ms 5012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 426 ms 33628 KB Output is correct
2 Correct 84 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 127812 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 127864 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 30712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 30572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 30712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 30200 KB Time limit exceeded
2 Halted 0 ms 0 KB -