螺旋矩阵问题+Queueing at Bank


螺旋矩阵问题



#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=10010;
int matrix[maxn][maxn],A[maxn];
bool cmp(int a,int b){
    return a>b;
}
int main(){
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    if(N==1){
        printf("%d",A[0]);
        return 0;
    }
    sort(A,A+N,cmp);
    int m=(int)cellsqrt(1.0*N);
    while(N%m!=0){
        m++;
    }
    int n=N/m,i=1,j=1,now=0;
    int U=1,D=m,L=1,R=n;
    while(now<N){
        while (now<N&&j<R) {
      matrix[i][j]=A[now++];
      j++;
        }
        while(now<N&&i<D){
            matrix[i][j]=A[now++];
            i++;
        }
        while(now<N&&j>L){
            matrix[i][j]=A[now++];
            j--;
        }
        while(now<N&&i>U){
            matrix[i][j]=A[now++];
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<n;j++){
            printf("%d",matrix[i][j]);
            if(j<n)printf(" ");
            else
             printf("\n");
        }
    }
    return 0;
}

Queueing at Bank



#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int K=111;
const int INF=1000000000;
struct Customer{
    int comeTime,serveTime;
}newCustomer;
vector<Customer>custom;
int convertTime(int h,int m,int s){
    return h*3600+m*60+s;
}
bool cmp(Customer a,Customer b){
    return a.comeTime<b.comeTime;
}
int endTime[K];
int main(){
    int c,w,totTime=0;
    int StTime=convertTime(8, 0, 0);
    int edTime=convertTime(17, 0, 0);
    scanf("%d%d",&c,&w);
    for(int i=0;i<w;i++)
    endTime[i]=StTime;
    for(int i=0;i<c;i++){
        int h,m,s,serveTime;
        scanf("%d:%d:%d %d",&h,&m,&s,&serveTime);
        int comeTime=convertTime(h,m,s);
        if(comeTime>edTime)continue;
        newCustomer.comeTime=comeTime;
        newCustomer.serveTime=serveTime<=60?serveTime*60:3600;
        custom.push_back(newCustomer);
    }
    sort(custom.begin(),custom.end(),cmp);
    for(int i=0;i<custom.size();i++){
        int idx=-1,minEndTime=INF;
        for(int j=0;j<w;j++){
        if(endTime[j]<minEndTime){
            minEndTime=minEndTime;
            idx=j;
        }
    }
    if(endTime[idx]<=custom[i].comeTime){
        endTime[idx]=custom[i].comeTime+custom[i].serveTime;
    }else {
    totTime+=(endTime[idx]-custom[i].comeTime);
    endTime[idx]+=custom[i].serveTime;
    }
    }
    if(custom.size()==0)printf("0.0");
    else
     printf("%.lf",totTime/60.0/custom.size());
     return 0;
}

Queueing theory is a mathematical study of waiting lines or queues that arise in various real-life scenarios, such as customer service, traffic congestion, hospital emergency rooms, and telecommunications networks. Basic queueing theory involves the following concepts: 1. Arrival Process: This is the process of customers arriving at the queue. The arrival process can be modeled using different distributions, such as Poisson or exponential. 2. Service Process: This is the process of serving customers in the queue. The service process can also be modeled using different distributions, such as Poisson or exponential. 3. Queue Length: This is the number of customers waiting in the queue at any given time. 4. Queue Occupancy: This is the proportion of time that the server is busy serving customers. 5. System Capacity: This is the maximum number of customers that the system can handle at any given time. 6. Utilization: This is the proportion of time that the server is busy serving customers compared to the total time. 7. Waiting Time: This is the time that a customer spends waiting in the queue before being served. 8. Service Time: This is the time that a customer spends being served by the server. 9. Queueing Models: There are different queueing models that can be used to analyze queueing systems, such as the M/M/1 model, M/M/c model, M/G/1 model, and M/D/1 model. 10. Performance Measures: Different performance measures can be used to evaluate queueing systems, such as average waiting time, average queue length, and system throughput.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

超翔之逸

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值