求问,萌新思考两小时无果
  • 板块灌水区
  • 楼主Prolystic
  • 当前回复20
  • 已保存回复20
  • 发布时间2023/2/6 21:00
  • 上次更新2023/10/24 01:31:15
查看原帖
求问,萌新思考两小时无果
695863
Prolystic楼主2023/2/6 21:00

RT,这为什么会TLE啊啊啊,没思路,求指导 能帮忙提出一些指导意见吗谢谢

//
//  main.cpp
//  [PA2021 P9045]Oranzada(AC)
//
//  Created by Operator-Ace2022 on 2023/2/6.
//

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <cmath>
#include <string>
#define MAXN 1e5
struct fish
{
    long long big;
    int id;
};
bool cmp(fish a,fish b)
{
    if(a.big>b.big)
    {
        return true;
    }
    return false;
}
int n;
char ans[500005] = {};
fish a[500005] = {};
int main(int argc, const char * argv[])
{
    scanf("%lld",&n);
    for(int i = 1;i<=n;i++)
    {
        scanf("%lld",&a[i].big);
        a[i].id = i;
    }
    std::sort(a,a+n,cmp);
    for(int i = 1;i<n;i++)
    {
        long long temp = a[i].big;
        for(int j = i+1;j<n;j++)
        {
            if(temp>a[j].big)
            {
                temp+=a[j].big;
            }
        }
        for(int j = i-1;j>=0;j--)
        {
            if(temp>a[j].big)
            {
                temp+=a[j].big;
            }
        }
        if(a[0].big<temp)
        {
            ans[a[i].id] = 'T';
        }
        else
        {
            ans[a[i].id] = 'N';
        }
        temp = 0;
    }
    for(int i = 1;i<=n;i++)
    {
        printf("%c",ans[i]);
    }
    return 0;
}

2023/2/6 21:00
加载中...