关于#c++#的问题:pta L1-049 天梯赛座位分配

pta L1-049 天梯赛座位分配

为什么答案正确但是过不了

img

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
typedef long long LL;
const int INF = 1000005;
int n,m,ans=0,flag=0;
int a[110],b[110],minn=999;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
        minn=min(minn,a[i]);
    }
    sort(b+1,b+1+n);
    reverse(b+1,b+1+n);
//    for(int i=1;i<=n;i++)cout<
    for(int i=1;i<=n;i++)
    {
        cout<<"#"<int now=i;
        int add=n;
        for(int j=1;j<=a[i];j++)
        {
            if(j>b[add])
            {
                add--;
            }
            if(add<=2)add=2;
            for(int k=1;k<=10;k++)
            {
                cout<if(k<10)cout<<" ";
                else cout<//    cout<
        //    now+=add;
        }
        
    }
    
    
    return 0;    
} 

题目哪去了,还有没过的数据

  • 你可以看下这个问题的回答https://ask.csdn.net/questions/7630289
  • 这篇博客你也可以参考下:PTA 天梯赛 L1-006 连续因子 C++实现
  • 除此之外, 这篇博客: 【PTA】团体程序设计天梯赛-练习集 25分的题中的 L2-019 悄悄关注(模拟) 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 在这里插入图片描述
    输入1:

    10 GAO3 Magi Zha1 Sen1 Quan FaMK LSum Eins FatM LLao
    8
    Magi 50
    Pota 30
    LLao 3
    Ammy 48
    Dave 15
    GAO3 31
    Zoro 1
    Cath 60
    

    输出1:

    Ammy
    Cath
    Pota
    

    输入2:

    11 GAO3 Magi Zha1 Sen1 Quan FaMK LSum Eins FatM LLao Pota
    7
    Magi 50
    Pota 30
    LLao 48
    Ammy 3
    Dave 15
    GAO3 31
    Zoro 29
    

    输出2:

    Bing Mei You
    

    代码:

    #include<bits/stdc++.h>
    using namespace std;
    #define fir(i,a,n) for(int i=a;i<=n;i++)
    #define pb push_back
    #define ll long long
    const int N=1e4+10;
    int n,m;
    map<string,int>gz;
    struct node
    {
    	string name;
    	int zan;
    }p[N];
    vector<string>s;
    int main()
    {
    	cin>>n;
    	fir(i,1,n)
    	{
    		string a;cin>>a;
    		gz[a]=1;//关注了 
    	}
    	cin>>m;
    	int sum=0;
    	fir(i,1,m)	
    	{
    		string a;int b;cin>>a>>b;
    		sum+=b;
    		p[i]={a,b};
    	}
    	double pj=sum*1.0/m;
    	fir(i,1,m)
    	{
    		if(p[i].zan>pj&&gz[p[i].name]==0)
    		{
    			s.pb(p[i].name);
    		}
    	}
    	if(s.empty())
    	{
    		cout<<"Bing Mei You";
    	}
    	else
    	{
    		sort(s.begin(),s.end());
    		for(auto x:s) cout<<x<<endl;
    	}
    	return 0;
    }
    
  • 以下回答由chatgpt基于相关博客总结生成:

    由于问题不是很明确,我无法直接给出解决方案,但根据参考资料,我对冒泡排序和归并排序进行了简要说明,希望可以帮到你。如果你可以提供更多的信息,比如具体的测试数据导致的错误信息,可能我可以给出更具体的解决方案。