HDU ACM 11 2037 今年暑假不AC
2016-10-15 14:51
337 查看
贪吃算法
#include <iostream>
#include <algorithm>
using namespace std;
struct Lu
{
int x;
int y;
};Lu Hui[100];
int main()
{
int n;
while (cin >> n && n)
{
int j = 0;
int Yi = 1;
for (int i = 0; i < n; i++)
cin >> Hui[i].x >> Hui[i].y;
for (int i = 0; i < n; i++)
for (int x = i; x < n; x++)
if (Hui[i].y > Hui[x].y)
swap(Hui[i], Hui[x]);
for (int i = 1; i < n; i++)
if (Hui[i].x >= Hui[j].y)
{
Yi++;
j = i;
}
cout << Yi << endl;
}
return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;
struct Lu
{
int x;
int y;
};Lu Hui[100];
int main()
{
int n;
while (cin >> n && n)
{
int j = 0;
int Yi = 1;
for (int i = 0; i < n; i++)
cin >> Hui[i].x >> Hui[i].y;
for (int i = 0; i < n; i++)
for (int x = i; x < n; x++)
if (Hui[i].y > Hui[x].y)
swap(Hui[i], Hui[x]);
for (int i = 1; i < n; i++)
if (Hui[i].x >= Hui[j].y)
{
Yi++;
j = i;
}
cout << Yi << endl;
}
return 0;
}
相关文章推荐
- HDU ACM 2037 今年暑假不AC
- 贪心--HDU 2037今年暑假不AC
- hdoj2037 今年暑假不AC(贪心)
- HDU - 2037 今年暑假不AC (贪心模板 DP)
- HDU 2037 今年暑假不AC (结构体排序示例题)
- HDU 2037:今年暑假不AC
- HDOJ_2037今年暑假不AC
- 杭电 2037 今年暑假不AC
- hdu 2037 今年暑假不AC
- hdoj2037今年暑假不AC
- hdoj 2037 今年暑假不AC 【贪心】
- HDU 2037 今年暑假不ac!
- hdu 2037 今年暑假不AC
- hdu 2037 今年暑假不AC (贪心)
- HDU 2037 今年暑假不AC
- HDOJ 2037 今年暑假不AC
- HDU 2037 今年暑假不AC (贪心)
- HDU - 2037 今年暑假不AC
- HDU 2037 今年暑假不AC
- hdu 2037 今年暑假不AC