HD-ACM算法专攻系列(17)——find your present (2)
2017-10-07 15:40
375 查看
题目描述:
源码:
源码:
#include"iostream" #include"string" using namespace std; bool IsFirstHalf(string *strs, int n, string str) { int count = 0; for(int i = 0; i < n; i++) { if(str < strs[i])count++; } return count >= (n / 2 + n % 2); } int main() { int n, count[100], counts[5]; string **strs; strs = new string*[5]; for(int i = 0; i < 5; i++) { strs[i] = new string[100]; } while(cin>>n) { if(n < 0)break; counts[1] = counts[2] = counts[3] = counts[4] = 0; for(int i = 0; i < n; i++) { cin>>count[i]>>strs[0][i]; if(count[i] > 0 && count[i] < 5) { strs[count[i]][counts[count[i]]++] = strs[0][i]; } } for(int i = 0; i < n; i++) { switch(count[i]) { case 5: cout<<100<<endl; break; case 0: cout<<50<<endl; break; default: if(IsFirstHalf(strs[count[i]], counts[count[i]], strs[0][i])) { cout<<55 + 10 * count[i]<<endl; } else { cout<<50 + 10 * count[i]<<endl; } break; } } cout<<endl; } return 0; }
相关文章推荐
- HD-ACM算法专攻系列(14)——find your present (2)
- find your present (2) hd 2095
- 2095 find your present (2)
- hdu 2095 find your present (2)
- find your present (2)
- find your present (2)
- ACM STEP 1.2.4 find your present (2)
- HDU 2095 find your present (2)
- HD-ACM算法专攻系列(11)——Exponentiation
- HDOJ 2095 find your present (2)
- HDU 2095 find your present (2) 【异或】
- find your present (2)
- HDU 2095 find your present (2)
- 2095 find your present (2)【水题】
- find your present (2) 2095
- HD-ACM算法专攻系列(13)——How Many Fibs?
- hdu 2095 find your present (2)
- //水题//map和iterator//find your present (2)
- hdu 2095 find your present(2)
- hdu 2095 find your present (2)