标签: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); }
标签:bool second sort efi col war scanf printf bsp
原文地址:https://www.cnblogs.com/masayoshi/p/10867303.html