3 条题解

  • 7
    @ 2023-10-14 23:41:42
    #include<stdio.h>
    int main()
    {
    int T;
    scanf("%d",&T);
    while(T--)
    {
    int N,num[200]={0};
    scanf("%d",&N);
    int a,b,c;
    for(int i=0;i<N;i++)
    {
    scanf("%d%d%d",&a,&b,&c);
    for(int j=b;j<b+c;j++)//b到b+c添加本次内需要的房间
    {
    num[j]+=a;//不同次输入,内叠时间内叠加房间数
    }
    }
    int max=0;
    for(int i=1;i<190;i++)
    {
    if(num[max]<num[i])//取所有入住中同时入住的最大房间数,为最少房间数
    {
    max=i;
    }
    }
    printf("%d\n",num[max]);
    }
    }
    
    • @ 2024-10-24 20:02:18

      天才

    • @ 2024-10-24 20:02:38

      醍醐灌顶

    • @ 2025-11-21 19:52:44

      我很少夸别人,但是这次算你厉害👍

    • @ 2025-11-24 20:55:40

      天才🎉️

  • 2
    @ 2025-11-20 0:17:29
    #include<stdio.h>
    #include<algorithm>
    using namespace std;
    struct room {
    	int a;  
    	int b;  
    	int c;  
    };
    bool cmp(room p, room q) {
    	return p.b < q.b;
    }
    int main() {
    	int t;
    	scanf("%d", &t);
    	while (t--) {
    		int n;
    		scanf("%d", &n);
    		room s[n + 10];		
    		for (int i = 0; i < n; i++) {
    			scanf("%d%d%d", &s[i].a, &s[i].b, &s[i].c);
    		}		
    		sort(s, s + n, cmp);   		
    		int max = -1000;
    		int arr[200] = {0}; 
    		for (int i = 0; i < n; i++) {
    			for (int j = s[i].b; j < s[i].b + s[i].c; j++) {
    				arr[j] += s[i].a;
    				if (arr[j] > max) {
    					max = arr[j];
    				}
    			}
    		}		
    		printf("%d\n", max);
    	}
    	return 0;
    }
    
    • @ 2025-11-20 0:19:41

      结构体排序+不断通过更新最晚时间来更新房间数

  • 0
    @ 2025-11-17 18:10:46

    #include <iostream> using namespace std; int main() { int t; cin>>t; while(t--) { int n; cin>>n; int tong[200]={0}; for(int i=0;i<n;i++) { int a,b,c; cin>>a>>b>>c; for(int j=1;j<=a;j++) { for(int k=b;k<b+c;k++) { tong[k]++; } } } int max=0; for(int i=0;i<200;i++) { if(tong[i]>max) { max=tong[i]; } } cout<<max<<endl; } }

    • 1

    信息

    ID
    178
    时间
    3000ms
    内存
    128MiB
    难度
    6
    标签
    (无)
    递交数
    464
    已通过
    150
    上传者