답안 #540781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
540781 2022-03-21T17:26:06 Z AlperenT Akcija (COCI21_akcija) C++17
0 / 110
5000 ms 156216 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2000 + 5;

int n, k;

pair<int, int> arr[N];

struct Item{
    int k;
    long long c;

    bool operator < (const Item &sc) const{
        if(k == sc.k) return c < sc.c;
        else return k > sc.k;
    }
};

vector<Item> v;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    cin >> n >> k;

    for(int i = 1; i <= n; i++) cin >> arr[i].second >> arr[i].first;

    sort(arr + 1, arr + n + 1);

    for(int i = 1; i <= n; i++){
        int tmp = v.size();

        for(int j = 0; j < tmp; j++){
            if(v[j].k < arr[i].first) v.push_back({v[j].k + 1, v[j].c + arr[i].second});
        }

        v.push_back({1, arr[i].second});

        sort(v.begin(), v.end());

        while(v.size() > k * 2) v.pop_back();
    }

    for(int i = 0; i < min(k, (int)v.size()); i++) cout << v[i].k << " " << v[i].c << "\n";
    for(int i = 0; i < k - v.size(); i++) cout << 0 << " " << 0 << "\n";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:43:24: warning: comparison of integer expressions of different signedness: 'std::vector<Item>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |         while(v.size() > k * 2) v.pop_back();
      |               ~~~~~~~~~^~~~~~~
Main.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Item>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i = 0; i < k - v.size(); i++) cout << 0 << " " << 0 << "\n";
      |                    ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5053 ms 151416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5053 ms 151416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5053 ms 152616 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5068 ms 156216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5069 ms 152748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5053 ms 151416 KB Time limit exceeded
2 Halted 0 ms 0 KB -