ZOJ Problem Set - 3197 Google Book
2013-05-07 18:16
260 查看
#include <utility> #include <algorithm> #include <string> #include <cstring> #include <cstdio> #include <iostream> #include <iomanip> #include <set> #include <vector> #include <cmath> #include <queue> #include <bitset> #include <map> #include <iterator> using namespace std; #define clr(a,v) memset(a,v,sizeof(a)) #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 const int INF = 0x7f7f7f7f; const int maxn = 211111; const double pi = acos(-1.0); const double eps = 1e-8; const int mod = 777777777; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> pii; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; pii p[maxn]; int main() { ios::sync_with_stdio(false); int T, i, n; scanf("%d", &T); while (T--) { scanf("%d", &n); for (i = 0; i < n; ++i) { scanf("%d%d", &p[i].first, &p[i].second); } if (n == 1) { puts("1"); continue; } sort(p, p + n); int ma, ans = 0, now = 0; i = 0; while (now < n && i < n) { ma = 0; while (p[i].first <= now + 1 && i < n) { ma = max(ma, p[i].second); ++i; } now = ma; ++ans; } printf("%d\n", ans); } return 0; }
相关文章推荐
- ZOJ Problem Set - 1092Arbitrage
- ZOJ Problem Set - 3664 Split the Rectangle
- ZOJ Problem Set - 1027
- ZOJ Problem Set - 1151 Word Reversal
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
- ZOJ Problem Set - 1093 Monkey and Banana
- ZOJ Problem Set - 1009 Enigma
- ZOJ Problem Set - 1025 Wooden Sticks
- ZOJ Problem Set - 1579 Bridge
- ZOJ Problem Set - 1051
- ZOJ Problem Set - 3829Known Notation(贪心)
- ZOJ Problem Set - 1076
- ZOJ Problem Set - 2100 (DFS)
- ZOJ Problem Set–1494 Climbing Worm
- ZOJ Problem Set - 1004-Anagrams by Stack
- ZOJ Problem Set - 1115||Digital Roots
- ZOJ Problem Set - 1037
- ZOJ Problem Set - 1016 Parencodings
- ACM ZOJ Problem Set - 1002 fire net
- ZOJ Problem Set–1763 A Simple Question of Chemistry