3 4 10 20 30 40 50 60 70 80 2 1 3 2 200 3 10 100 20 80 30 50
10 20 30
#include <map> #include <set> #include <cmath> #include <ctime> #include <queue> #include <vector> #include <cctype> #include <cstdio> #include <string> #include <cstring> #include <sstream> #include <cstdlib> #include <iostream> #include <algorithm> #include <functional> using namespace std; #define pb push_back #define mp make_pair #define fillchar(a, x) memset(a, x, sizeof(a)) #define copy(a, b) memcpy(a, b, sizeof(a)) #define lson rt << 1, l, mid #define rson rt << 1|1, mid + 1, r typedef long long LL; typedef pair<int, int > PII; typedef unsigned long long uLL; template<typename T> void print(T* p, T* q, string Gap = " ") { int d = p < q ? 1 : -1; while(p != q) { cout << *p; p += d; if(p != q) cout << Gap; } cout << endl; } template<typename T> void print(const T &a, string bes = "") { int len = bes.length(); if(len >= 2)cout << bes[0] << a << bes[1] << endl; else cout << a << endl; } const int INF = 0x3f3f3f3f; const int MAXM = 2e5; const int MAXN = 200 + 5; int T, N; int X[MAXN]; int main(){ scanf("%d", &T); while(T --){ scanf("%d", &N); int a, b, res = 0; memset(X, 0, sizeof(X)); for(int i = 0;i < N;i ++){ scanf("%d%d", &a, &b); if(a > b) swap(a, b); a = (a + 1) >> 1; b = (b + 1) >> 1; for(int i = a;i <= b;i ++){ X[i] ++; res = max(res, X[i]); } } printf("%d\n", res * 10); } return 0; }
#include <map> #include <set> #include <cmath> #include <ctime> #include <queue> #include <vector> #include <cctype> #include <cstdio> #include <string> #include <cstring> #include <sstream> #include <cstdlib> #include <iostream> #include <algorithm> #include <functional> using namespace std; #define pb push_back #define mp make_pair #define fillchar(a, x) memset(a, x, sizeof(a)) #define copy(a, b) memcpy(a, b, sizeof(a)) #define lson rt << 1, l, mid #define rson rt << 1|1, mid + 1, r typedef long long LL; typedef pair<int, int > PII; typedef unsigned long long uLL; template<typename T> void print(T* p, T* q, string Gap = " ") { int d = p < q ? 1 : -1; while(p != q) { cout << *p; p += d; if(p != q) cout << Gap; } cout << endl; } template<typename T> void print(const T &a, string bes = "") { int len = bes.length(); if(len >= 2)cout << bes[0] << a << bes[1] << endl; else cout << a << endl; } const int INF = 0x3f3f3f3f; const int MAXM = 2e5; const int MAXN = 200 + 5; int T, N; pair<int, int >Q[MAXN]; bool Ires[MAXN]; int main(){ scanf("%d", &T); while(T --){ memset(Ires, false, sizeof(Ires)); scanf("%d", &N); for(int i = 0;i < N;i ++){ scanf("%d%d", &Q[i].first, &Q[i].second); if(Q[i].first > Q[i].second) swap(Q[i].first, Q[i].second); Q[i].second = (Q[i].second + 1) >> 1; Q[i].first = (Q[i].first + 1) >> 1; } sort(Q, Q + N); int r = 0; while(true){ int res = 0; int cur = 0; for(int i = 0;i < N;i ++){ res += Ires[i]; } if(res == N) break; for(int i = 0;i < N;i ++){ if(cur < Q[i].first && !Ires[i]){ cur = Q[i].second; Ires[i] = true; } } r += 10; } printf("%d\n", r); } return 0; }