求助各位大佬,为什么too many or too few lines?

P1168 中位数

柠檬味丶 @ 2017-10-08 19:45:29

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[50099],b[50099],c[2];
int main()
{
    int kb=1,ka=1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>c[i%2];
        if(i==1)
        {
            b[1]=c[1];
            make_heap(b+1,b+1,greater<int>());
            make_heap(a+1,a+1);
            cout<<b[1]<<endl;
            continue;
        }
        if(i%2==1)
        {
            if(c[1]>b[1]&&c[0]>b[1])
            {
                int cmp=b[1];
                pop_heap(b+1,b+1+kb,greater<int>());
                b[kb]=c[0];
                kb++;
                b[kb]=c[1];
                make_heap(b+1,b+1+kb,greater<int>());
                ka++;
                a[ka]=cmp;
                make_heap(a+1,a+1+ka);
                cout<<b[1]<<endl;
            }
            if(c[1]<b[1]&&c[0]<b[1])
            {
                int cmp=a[1];
                pop_heap(a+1,a+1+ka);
                a[ka]=c[0];
                ka++;
                a[ka]=c[1];
                make_heap(a+1,a+1+ka);
                kb++;
                b[kb]=cmp;
                make_heap(b+1,b+1+kb,greater<int>());
                cout<<b[1]<<endl;
            }
            if(c[1]<b[1]&&c[0]>b[1])
            {
                ka++;
                a[ka]=c[1];
                make_heap(a+1,a+1+ka);
                kb++;
                b[kb]=c[0];
                make_heap(b+1,b+1+kb,greater<int>());
                cout<<b[1]<<endl;
            }
            if(c[1]>b[1]&&c[0]<b[1])
            {
                ka++;
                a[ka]=c[0];
                make_heap(a+1,a+1+ka);
                kb++;
                b[kb]=c[1];
                make_heap(b+1,b+1+kb,greater<int>());
                cout<<b[1]<<endl;
            }
        }
    }
}

by Tao濤 @ 2020-05-29 00:06:43

这一题它不忽略行末回车 所以你输出的最后一行必须是答案 而不是回车


|