解题思路:
注意事项:
参考代码:
#include<iostream> #include<algorithm> #include<queue> #include<vector> using namespace std; const int N=25; struct Window{ int id; int ltime; bool operator <(const Window &t) const { if(ltime==t.ltime) return id<t.id; else return ltime<t.ltime; } }q[N]; int main() { int n,m; while(scanf("%d", &n) != EOF) { scanf("%d", &m); double avg=0; for(int i=0;i<n;i++) q[i].ltime=0,q[i].id=i; for(int i=0;i<m;i++) { stable_sort(q,q+n); int time,serve; cin>>time>>serve; if(q[0].ltime<=time) q[0].ltime=time+serve; else if(q[0].ltime>time) { avg+=q[0].ltime-time; q[0].ltime+=serve; } } avg/=m; printf("%.2lf\n",avg); } return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1282 |
简单的a+b (C语言代码)浏览:414 |
A+B for Input-Output Practice (V) (C语言代码)浏览:459 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:552 |
矩阵乘方 (C语言代码)浏览:1022 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:534 |
1050题解(结构体数组与结构体指针的使用)浏览:1106 |
一元一次方程 (C语言代码)浏览:4059 |
矩阵的对角线之和 (C语言代码)浏览:1344 |
1231题解(注意理解“输入多个测试实例”)浏览:785 |