Submission #540786

# Submission time Handle Problem Language Result Execution time Memory
540786 2022-03-21T17:43:39 Z AlperenT Akcija (COCI21_akcija) C++17
10 / 110
790 ms 596 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() > N * 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 - (int)v.size(); i++) cout << 0 << " " << 0 << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 257 ms 572 KB Output is correct
2 Correct 271 ms 568 KB Output is correct
3 Correct 253 ms 468 KB Output is correct
4 Correct 278 ms 572 KB Output is correct
5 Correct 281 ms 572 KB Output is correct
6 Correct 21 ms 340 KB Output is correct
7 Correct 94 ms 524 KB Output is correct
8 Correct 71 ms 572 KB Output is correct
9 Correct 89 ms 468 KB Output is correct
10 Correct 157 ms 572 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 257 ms 572 KB Output is correct
2 Correct 271 ms 568 KB Output is correct
3 Correct 253 ms 468 KB Output is correct
4 Correct 278 ms 572 KB Output is correct
5 Correct 281 ms 572 KB Output is correct
6 Correct 21 ms 340 KB Output is correct
7 Correct 94 ms 524 KB Output is correct
8 Correct 71 ms 572 KB Output is correct
9 Correct 89 ms 468 KB Output is correct
10 Correct 157 ms 572 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Incorrect 790 ms 572 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 769 ms 576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 596 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 5 ms 596 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 2 ms 468 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 41 ms 468 KB Output is correct
2 Incorrect 35 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 257 ms 572 KB Output is correct
2 Correct 271 ms 568 KB Output is correct
3 Correct 253 ms 468 KB Output is correct
4 Correct 278 ms 572 KB Output is correct
5 Correct 281 ms 572 KB Output is correct
6 Correct 21 ms 340 KB Output is correct
7 Correct 94 ms 524 KB Output is correct
8 Correct 71 ms 572 KB Output is correct
9 Correct 89 ms 468 KB Output is correct
10 Correct 157 ms 572 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Incorrect 790 ms 572 KB Output isn't correct
15 Halted 0 ms 0 KB -