hdu1084:What is your grade?
2014-11-05 13:36
489 查看
题目地址:
http://acm.hdu.edu.cn/showproblem.php?pid=1084
这道题要注意只有一个人做4.3.2.1道题时是90.80,70,60分,因为这坑了我好久!
还有注意下排序就OK了,简直水得不能再水了!
上AC代码:
#include<iostream>
#include<cmath>
#include<cstdio>
#include<queue>
#include<iomanip>
using namespace std;
const int maxn = 101;
struct Student{
int num;
int ID;
int time;
}st[maxn];
int ranks[4][2] = { { 65, 60 }, { 75, 70 }, { 85, 80 },{ 95, 90 } };
bool cmp(const Student &s1, const Student &s2){
return s1.num > s2.num || (s1.num == s2.num&&s1.time < s2.time);
}
int main(){
int n, a, b, c;
int T;
while (cin >> T, T != -1){
int i, j,t;
for (i = 0; i < T;i++){
scanf("%d %d:%d:%d", &n, &a, &b, &c);
int time = a * 60 * 60 + b * 60 + c;
st[i].ID = i;
st[i].num = n;
st[i].time = time;
}
sort(st, st + T, cmp);
int score[maxn];
int num = 0;
j=0;
int end=0;
int pres = -1;
bool flag1=false;
bool flag = false;
for (i = 0; i < T; i++){
if (st[i].num == 5){
score[st[i].ID] = 100;
}
else if(st[i].num==0){
if(flag&&!flag1){
end=i;
flag1=true;
}
score[st[i].ID] = 50;
}
else if(pres==st[i].num){
num++;
end=i+1;
flag=true;
}
else{
if(flag){
int mid = num / 2;
for (t = j; t < j+mid; t++){
score[st[t].ID] = ranks[st[t].num - 1][0];
}
for (t = j + mid; t < i; t++){
score[st[t].ID] = ranks[st[t].num - 1][1];
}
}
num = 1;
pres = st[i].num;
score[st[i].ID]=ranks[st[i].num-1][1];
j = i;
flag=false;
}
}
if(flag&&j<end){
int mid = num / 2;
for (t = j; t < j+mid; t++){
score[st[t].ID] = ranks[st[t].num - 1][0];
}
for (t = j + mid; t < end; t++){
score[st[t].ID] = ranks[st[t].num - 1][1];
}
}
for (i = 0; i < T; i++){
printf("%d\n", score[i]);
}
printf("\n");
}
return 0;
}
http://acm.hdu.edu.cn/showproblem.php?pid=1084
这道题要注意只有一个人做4.3.2.1道题时是90.80,70,60分,因为这坑了我好久!
还有注意下排序就OK了,简直水得不能再水了!
上AC代码:
#include<iostream>
#include<cmath>
#include<cstdio>
#include<queue>
#include<iomanip>
using namespace std;
const int maxn = 101;
struct Student{
int num;
int ID;
int time;
}st[maxn];
int ranks[4][2] = { { 65, 60 }, { 75, 70 }, { 85, 80 },{ 95, 90 } };
bool cmp(const Student &s1, const Student &s2){
return s1.num > s2.num || (s1.num == s2.num&&s1.time < s2.time);
}
int main(){
int n, a, b, c;
int T;
while (cin >> T, T != -1){
int i, j,t;
for (i = 0; i < T;i++){
scanf("%d %d:%d:%d", &n, &a, &b, &c);
int time = a * 60 * 60 + b * 60 + c;
st[i].ID = i;
st[i].num = n;
st[i].time = time;
}
sort(st, st + T, cmp);
int score[maxn];
int num = 0;
j=0;
int end=0;
int pres = -1;
bool flag1=false;
bool flag = false;
for (i = 0; i < T; i++){
if (st[i].num == 5){
score[st[i].ID] = 100;
}
else if(st[i].num==0){
if(flag&&!flag1){
end=i;
flag1=true;
}
score[st[i].ID] = 50;
}
else if(pres==st[i].num){
num++;
end=i+1;
flag=true;
}
else{
if(flag){
int mid = num / 2;
for (t = j; t < j+mid; t++){
score[st[t].ID] = ranks[st[t].num - 1][0];
}
for (t = j + mid; t < i; t++){
score[st[t].ID] = ranks[st[t].num - 1][1];
}
}
num = 1;
pres = st[i].num;
score[st[i].ID]=ranks[st[i].num-1][1];
j = i;
flag=false;
}
}
if(flag&&j<end){
int mid = num / 2;
for (t = j; t < j+mid; t++){
score[st[t].ID] = ranks[st[t].num - 1][0];
}
for (t = j + mid; t < end; t++){
score[st[t].ID] = ranks[st[t].num - 1][1];
}
}
for (i = 0; i < T; i++){
printf("%d\n", score[i]);
}
printf("\n");
}
return 0;
}
相关文章推荐
- HDU1084:What Is Your Grade?
- hdu1084(What Is Your Grade?)
- 【water】HDU1084 What Is Your Grade?
- 【结构体排序】HDU1084 What Is Your Grade?
- HDU1084 What Is Your Grade?(水题,简单)
- HDU1084 What Is Your Grade?
- Hdu1084 What Is Your Grade?
- HDU 1084:What Is Your Grade?
- 【杭电1084】What Is Your Grade?
- HDU 1084 What Is Your Grade?
- 杭电ACM HDU 1084 What Is Your Grade?
- What Is Your Grade?(1084)
- HDU 1084 What Is Your Grade?
- HDU-1084-What Is Your Grade?
- HDU/HDOJ 1084 What Is Your Grade?
- HDOJ 1084 What Is Your Grade?
- 文章标题杭电What Is Your Grade?
- What Is Your Grade?
- What Is Your Grade? (sort)
- HDOJ1084 What Is Your Grade?