題意:公司有400個房間,單號對雙號對門,中間有一條走廊,
現在要搬東西,給出要搬的次數,還有每次搬動的房間號,
每次搬動需要10分鐘,搬動過程中的那段走廊不能被使用,
求最大搬動時長。
解析:
按a從大到小排序。.由於奇偶數分列兩邊,所以需要將奇偶數房間號做一下變換:
如果值是奇數,則該值除以2再+1;如果是偶數直接除以二,此時號的範圍變成1~200
ac代碼:
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
using namespace std;
const int N=202;
int main()
{
int c;
scanf("%d",&c);
while(c--){
int m,n;
int start,end;
int i;//拌勻次數
int ccount[N];
scanf("%d",&i);
memset(ccount,0,sizeof(ccount));
for(m=0;m<i;m++)
{
scanf("%d%d",&start,&end);
start=(start-1)/2;
end=(end-1)/2;
if(start>end){
int temp=start;
start=end;
end=temp;
}
for(n=start;n<=end;n++)
ccount[n]++;
}
int max=0;
for(m=0;m<N;m++)
if(ccount[m]>max) max=ccount[m];
printf("%d\n",max*10);
}
return 0;
}