7点AC,4点TLE求助。
查看原帖
7点AC,4点TLE求助。
478723
GXH090612楼主2021/2/1 08:26
//
//  main.cpp
//  P1631
//
//  Created by guozl on 2021/2/1.
//  Copyright © 2021 guozl. All rights reserved.
//

#include <cstdio>
#include <queue>

using namespace std;

priority_queue<int,vector<int>,greater<int> >q;
queue<int>a,b;
int n;

int main(int argc, const char * argv[]) {
    scanf("%d",&n);
    for (int i=0; i<n; ++i) {
        int x;
        scanf("%d",&x);
        a.push(x);
    }
    for (int i=0; i<n; ++i) {
        int x;
        scanf("%d",&x);
        b.push(x);
    }
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            q.push(a.front()+b.front());
            b.push(b.front());
            b.pop();
        }
        a.push(a.front());
        a.pop();
    }
    for (int i=0; i<n; ++i) {
        printf("%d ",q.top());
        q.pop();
    }
    return 0;
}
2021/2/1 08:26
加载中...