Submission
Status:
PP---P----
Score: 30
User: Jokul
Problemset: ไฟส่อง
Language: c
Time: 0.001 second
Submitted On: 2025-04-12 11:37:21
#include <stdio.h>
int main() {
int n, max = 0;
scanf("%d", &n);
int a[n], b[n];
// Input angles
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
scanf("%d", &b[i]);
}
// Calculate maximum range
for (int i = 0; i < n; i++) {
// Adjust for wrapping
if (b[i] < a[i]) {
b[i] += 360;
}
// Update max range
if (max < (b[i] - a[i])) {
max = b[i] - a[i];
}
}
// Check for overlaps with other intervals
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j) {
continue; // Skip the same interval
}
// Adjust for wrapping
int adjusted_b_j = b[j] < a[j] ? b[j] + 360 : b[j];
if (a[j] <= b[i] && adjusted_b_j >= b[i]) {
if (max < (adjusted_b_j - a[i])) {
max = adjusted_b_j - a[i];
}
}
}
}
// Output the result
if (max >= 360) {
printf("360\n");
} else {
printf("%d\n", max);
}
return 0;
}