📄 2037 今年暑假不ac.cpp
字号:
/*
2037 今年暑假不AC
Time Limit : 1000 ms Memory Limit : 32768 K Output Limit : 256 K
GUN C++
*/
#include <iostream>
#include <string>
using namespace std;
const int Max=100;
typedef struct
{
int ti_s;
int ti_e;
}Channel;
Channel table[Max+1];
int Partition(int low,int high)
{
Channel temp;
temp=table[low];
while(low!=high)
{
while( low<high && ( table[high].ti_e > temp.ti_e )
|| ((table[high].ti_e == temp.ti_e) && (table[high].ti_s > temp.ti_s)) )
high--;
table[low]=table[high];
while( low<high && ( table[low].ti_e < temp.ti_e )
|| ((table[low].ti_e == temp.ti_e) && (table[low].ti_s < temp.ti_s)) )
low++;
table[high]=table[low];
}//while
table[low]=temp;
return low;
}
int Qsort(int low,int high)
{
int partloc;
if(high>low)
{
partloc=Partition(low,high);
Qsort(low,partloc-1);
Qsort(partloc+1,high);
}
return 1;
}
int main()
{
int n,now,i,j,ans,end;
while(cin>>n && n!=0)
{
memset(table,0,sizeof(table));
for(i=0;i<n;i++)
cin>>table[i].ti_s>>table[i].ti_e;
Qsort(0,n-1);
ans=1;
end=table[0].ti_e;
for(i=1;i<n;i++)
{
if(table[i].ti_s>=end)
{ ans++;end=table[i].ti_e;}
}
cout<<ans<<endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -