noip普及组2004 不高兴的津津

sort

#include 
#include 
using namespace std;
//ifstream cin("unhappy.in",ios :: in);
//ofstream cout("unhappy.out",ios :: out);
struct NotHappy {
  int Time1,Time2;
  int day;
}week[8];
inline bool cmp(NotHappy a,NotHappy b) {
  //按Time1+Time2从大到小
  return a.Time1+a.Time2 > b.Time1+b.Time2;
}
int main() {
  ios :: sync_with_stdio(false);
  for (int i = 1;i <= 7;i++) {
    week[i].day = i;  //day表示星期几
    cin >> week[i].Time1 >> week[i].Time2;
  }
  sort(week+1,week+7,cmp);  //排序,规则:cmp
  //排序后最不高兴的就是week[1].day
  if (week[1].Time1+week[1].Time2 <= 8) cout << 0;
  else cout << week[1].day;
  return 0;
}


你可能感兴趣的:(noip,模拟)