谜之全WA??求大佬帮查
查看原帖
谜之全WA??求大佬帮查
470001
zbwcom楼主2021/8/27 11:54
#include <bits/stdc++.h>
using namespace std;
int n,m,k;
int total_time;
int t[1005],go[1005],end[1005];
int temp1[1005],temp2[1005],temp3[1005];
struct node{
    int from;
    int to;
    int time;
}road[1005];
struct edge1{
    int go;
    int end;
    int t;
}passenger[10005];
struct edge2{
    int id;
    int a1;
    int a2;
    int chengji;
}cunchu[1005];
bool cmp1(edge2 a,edge2 b){
    return a.chengji<b.chengji;
}
int main(){
    // freopen("bus.in","r",stdin);
    // freopen("bus.out","w",stdout);
    scanf("%d %d %d",&n,&m,&k);
    for(register int i=1;i<n;i++){
        scanf("%d",&road[i].time);
        road[i].from=i;
        road[i].to=i+1;
    }
    memset(temp1,-0x3f3f3f3f,sizeof(temp1));
    for(register int i=1;i<=m;i++){
        scanf("%d %d %d",&passenger[i].t,&passenger[i].go,&passenger[i].end);
        temp1[passenger[i].go]=max(passenger[i].t,temp1[passenger[i].go]);
        for(register int j=passenger[i].go;j<passenger[i].end;j++){
            temp2[j]++;
        }
    }
    if(k==0){
        for(register int i=2;i<=n;i++){
            temp3[i]=temp1[i-1]+road[i-1].time;
        }    
        for(register int i=1;i<=m;i++){
            total_time=total_time+temp3[passenger[i].end]-passenger[i].t;
        }
        printf("%d",total_time);
        return 0;
    }else{
        for(register int i=1;i<=n;i++){
            cunchu[i].a1=temp2[i];
            cunchu[i].a2=road[i].time;
            cunchu[i].chengji=cunchu[i].a1*cunchu[i].a2;
            cunchu[i].id=i;
        }
        sort(cunchu+1,cunchu+1+n,cmp1);
        if(k==1){
            road[cunchu[n].id].time-=1;
            for(register int i=2;i<=n;i++){
                temp3[i]=temp1[i-1]+road[i-1].time;
            }    
            for(register int i=1;i<=m;i++){
                total_time=total_time+temp3[passenger[i].end]-passenger[i].t;
            }
            printf("%d",total_time);         
            return 0;   
        }else{
            int h=n;
            int l=cunchu[n].id;
            while(road[l].time>0){
                road[l].time-=1;
                k-=1;
                if(k==0) break;
                if(road[l].time==0) l=cunchu[h-1].id;                
            }
            for(register int i=2;i<=n;i++){
                temp3[i]=temp1[i-1]+road[i-1].time;
            }    
            for(register int i=1;i<=m;i++){
                total_time=total_time+temp3[passenger[i].end]-passenger[i].t;
            }
            printf("%d",total_time);         
            return 0;   
        }
    }
    return 0;
}
2021/8/27 11:54
加载中...