解題報告:poj1083 Moving tables
阿新 • • 發佈:2017-09-02
分鐘 直接 簡單的 技術分享 n) size eof mes using
2017-09-02 19:49:59
writer:pprp
題意說明:
比較簡單的題,一開始被嚇到了,後來才發現,其實可以用很簡單的方法就可以解決;
就是在這樣的房間中如果在i 和 j 中之後的10分鐘內就不可以經過別的路線的桌子,給你幾組數據問你最短時間搬完這些桌子;
分析:
其實不是很難,不要往線段樹之類的數據結構去考了,這就是一個簡單題,
直接遍歷(a-1)/2 到 (b-1)/2就可以了,開一個200的數組,進行操作就OK了
代碼如下·:
/*
@theme:poj1083
@writer:pprp
@begin:19:30
@end:19:50
@declare:很簡單的遍歷就OK
@error:審題要仔細,理解題意,
不能只理解大概,記得要把freopen給註釋了再提交
@date:2017/9/2
*/
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int arr[200];
int main()
{
freopen("in.txt","r",stdin);
int cas, N, Max = 0;
int a, b;
cin >> cas;
while(cas--)
{
Max = -10;
memset(arr,0,sizeof(arr));
cin >> N;
for(int i = 0 ; i < N ; i++)
{
cin >> a >> b;//to mentain a < b
if(a > b)
swap(a,b);
for(int i = (a-1)/2 ; i <= (b-1)/2 ; i++)
{
arr[i]++;
}
}
for (int i = 0 ; i < 200; i++)
{
Max = max(Max,arr[i]);
}
cout << Max * 10 << endl;
}
return 0;
}
解題報告:poj1083 Moving tables