码迷,mamicode.com
首页 > 其他好文 > 详细

1017

时间:2019-05-15 09:25:33      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:bool   second   sort   efi   col   war   scanf   printf   bsp   

 

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
struct customers
{
    int time,hour,minute,second,process;
};
bool cmp(customers a,customers b){
    return a.time < b.time;
}
int main(){
    int n, k;
    cin >> n >> k;
    vector<customers> v(n);
    for (int i = 0; i < n; i++) {
        scanf("%d:%d:%d %d", &v[i].hour, &v[i].minute, &v[i].second,&v[i].process);
        v[i].time = v[i].hour * 60 * 60 + v[i].minute * 60 + v[i].second;
    }
    sort(v.begin(), v.end(), cmp);
    vector<int> windows(k,28800);
    double totoltime = 0.0;
    for (int i = 0; i < n; i++) {
        int min = windows[0], tempwindow = 0;
        for (int j = 1; j < k; j++) {
            if (min > windows[j]) {
                min = windows[j];
                tempwindow=j;
            }
        }
        if (v[i].time >= windows[tempwindow]) {
            windows[tempwindow] = v[i].time + v[i].process;
        }
        else {
            totoltime += windows[tempwindow] - v[i].time;
            windows[tempwindow]  += v[i].process;
        }
    }
    printf("%.1f", totoltime / 60 / n);
}

 

1017

标签:bool   second   sort   efi   col   war   scanf   printf   bsp   

原文地址:https://www.cnblogs.com/masayoshi/p/10867303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!