SOJ-3327
来源:互联网 发布:css div布局源码下载 编辑:程序博客网 时间:2024/04/29 22:24
/****************************************************************************************************** ** Copyright (C) 2011.05.01 - 2013.07.01 ** Author: famousDT <13730828587@163.com> ** Edit date: 2011-04-27******************************************************************************************************/#include <stdio.h>#include <stdlib.h>//abs,atof(string to float),atoi,atol,atoll#include <math.h>//atan,acos,asin,atan2(a,b)(a/b atan),ceil,floor,cos,exp(x)(e^x),fabs,log(for E),log10#include <vector>#include <queue>#include <map>#include <set>#include <string>#include <iostream>#include <string.h>//memcpy(to,from,count#include <ctype.h>//character process:isalpha,isdigit,islower,tolower,isblank,iscntrl,isprint#include <algorithm>using namespace std;//typedef long long int ll;#define PI acos(-1)#define MAX(a, b) ((a) > (b) ? (a) : (b))#define MIN(a, b) ((a) < (b) ? (a) : (b))#define MALLOC(n, type) ((type *)malloc((n) * sizeof(type)))#define FABS(a) ((a) >= 0 ? (a) : (-(a)))//贪心专题//http://cs.scu.edu.cn/soj/contest/contest.action?cid=212struct my{ int x, y; int z;}wo[100005];bool cmp(my a, my b){ if (a.z > b.z) return true; else if (a.z == b.z) return a.x > b.x; else return false;}int main(){ int n; int i, j; int a, b; cin>>n; while (n--) { cin>>a>>b; for (i = 0; i < a; ++i) { cin>>wo[i].x>>wo[i].y; wo[i].z = wo[i].x - wo[i].y; } sort(wo, wo + a, cmp); for (i = 0; i < a; ++i) { if (wo[i].x <= b) b -= wo[i].y; else break; } printf("%s\n", i == a ? "Clever Dahema" : "Stupid Dahema"); } return 0;}