답안 #3959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3959 2013-08-31T09:44:28 Z movie_jo Evaluation (kriii1_E) C
0 / 1
2000 ms 4992 KB
#include <stdio.h>

#define DIV 1000000007

long long a[100000], b[100000], c[100000], d[100000], p[100000];

int main(void)
{
	int N;
	long long S = 0, i, j, n, m;

	scanf("%d", &N);

	for(i = 0; i < N; i++)
	{
		scanf("%lld %lld %lld %lld %lld", a + i, b + i, c + i, d + i, p + i);

		S = (S + p[i]*p[i]*((c[i] - a[i] + 1)*(d[i] - b[i] + 1)%DIV))%DIV;

		for(j = 0; j < i; j++)
		{
			if(a[i] <= c[j] && c[i] >= a[j] && b[i] <= d[j] && d[i] >= b[j])
			{
				n = (c[i] > c[j]?c[j]:c[i]) - (a[i] > a[j]?a[i]:a[j]) + 1;
				m = (d[i] > d[j]?d[j]:d[i]) - (b[i] > b[j]?b[i]:b[j]) + 1;
				
				S = (S + 2*p[i]*p[j]*(n*m%DIV))%DIV;
			}
		}
	}

	printf("%lld\n", S);

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4992 KB Output is correct
2 Correct 0 ms 4992 KB Output is correct
3 Correct 0 ms 4992 KB Output is correct
4 Correct 0 ms 4992 KB Output is correct
5 Correct 0 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 4 ms 4992 KB Output is correct
10 Correct 4 ms 4992 KB Output is correct
11 Correct 428 ms 4992 KB Output is correct
12 Correct 480 ms 4992 KB Output is correct
13 Correct 432 ms 4992 KB Output is correct
14 Correct 484 ms 4992 KB Output is correct
15 Correct 432 ms 4992 KB Output is correct
16 Execution timed out 2000 ms 4988 KB Program timed out
17 Halted 0 ms 0 KB -