Codeforces Round #260 (Div. 2)
A. Laptops http://codeforces.com/contest/456/problem/A
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 const int M=100010; 5 struct G{ 6 int x,y; 7 friend bool operator <(G a,G b){ 8 return a.x<b.x; 9 } 10 }g[M]; 11 int main(){ 12 int n; 13 while(~scanf("%d",&n)){ 14 for(int i=0;i<n;i++){ 15 scanf("%d%d",&g[i].x,&g[i].y); 16 } 17 sort(g,g+n); 18 bool flag=false; 19 for(int i=0;i<n-1;i++){ 20 if(g[i].y>g[i+1].y){ 21 flag=true; 22 break; 23 } 24 } 25 if(flag) puts("Happy Alex"); 26 else puts("Poor Alex"); 27 } 28 return 0; 29 }
B. Fedya and Maths http://codeforces.com/contest/456/problem/B
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 const int M=100010; 3 char a[M]; 4 int id2[]={1,2,4,3}; 5 int id3[]={1,3,4,2}; 6 int id4[]={1,4}; 7 int getid(int op){ 8 int res=0; 9 for(int i=0;a[i];i++){ 10 res=((res<<3)+(res<<1)+a[i]-'0')%op; 11 } 12 return res; 13 } 14 int main(){ 15 while(~scanf("%s",a)){ 16 int ans=1+id2[getid(4)]+id3[getid(4)]+id4[getid(2)]; 17 printf("%d\n",ans%5); 18 } 19 return 0; 20 }
C. Boredom http://codeforces.com/contest/456/problem/C
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #define mt(a,b) memset(a,b,sizeof(a)) 5 using namespace std; 6 typedef __int64 LL; 7 const int M=100010; 8 int a[M]; 9 LL dp[M][2]; 10 int main(){ 11 int n,x; 12 while(~scanf("%d",&n)){ 13 mt(a,0); 14 for(int i=0;i<n;i++){ 15 scanf("%d",&x); 16 a[x]++; 17 } 18 dp[0][0]=dp[0][1]=0; 19 for(int i=1;i<=100001;i++){ 20 dp[i][0]=max(dp[i-1][0],dp[i-1][1]); 21 dp[i][1]=dp[i-1][0]+(LL)a[i]*i; 22 } 23 printf("%I64d\n",dp[100001][0]); 24 } 25 return 0; 26 }
end