[NYOJ] [acm-178] Room Arrangement

Problem Description

Loading...

Problem Analysis

Supposedly a problem from the 3rd Henan Provincial Programming Contest
Last winter break I tried a sorting approach and got WA
This time I solved it
【HDU】[4883]TIANKENG’s restaurant
Felt this problem could be done with the same idea

Gave it a try
Just use an array to record the number of rooms needed at the same time
Then when outputting, just find the maximum count needed in each time period

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<stdio.h>
int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		int a[200];
		for(int i=0; i<200; i++)
			a[i]=0;
		int n;
		scanf("%d",&n);
		while(n--) {
			int t,x,y;
			scanf("%d %d %d",&t,&x,&y);
			for(int i=x; i<x+y; i++)
				a[i]+=t;
		}
		int max=0;
		for(int i=0; i<200; i++)
			if(a[i]>max)
				max=a[i];
		printf("%d\n",max);
	}
	return 0;
}

PS: Kept getting WA on ZZULI’s judge
But the standard solution provided by NYOJ got WA too
So it should be a problem with ZZULI’s judge data

Problem link:【NYOJ】[acm-178]Room Arrangement)

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...