Submission #972236

# Submission time Handle Problem Language Result Execution time Memory
972236 2024-04-30T09:12:03 Z Circling Akcija (COCI21_akcija) C++17
0 / 110
5000 ms 964 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int64_t n, k, w, d, cntr = 0;
    cin >> n >> k;
    vector<vector<int>> expiry;
    expiry.resize(n + 1);
    for (int i = 0; i < n; i++){
        cin >> w >> d;
        expiry[d].push_back(w);
    }
    vector<vector<int>> currbest, nextbest, currexp;
    currbest.resize(n + 1);
    currbest[0].push_back(0);
    for (int i = 1; i <= n; i++){
        sort(expiry[i].begin(), expiry[i].end());
        currexp.clear();
        currexp.resize(n + 1);
        currexp[0].push_back(0);
        for (int item: expiry[i]){
            for (int j = n - 1; j >= 0; j--){
                for (int expsetsum: currexp[j]) currexp[j + 1].push_back(item + expsetsum);
                sort(currexp[j + 1].begin(), currexp[j + 1].end());
                if (currexp[j + 1].size() > k) currexp[j + 1].resize(k);
            }
        }
        nextbest.clear();
        nextbest.resize(n + 1);
        for (int p1 = 0; p1 <= n; p1++){
            for (int p2 = 0; p1 + p2 <= n; p2++){
                for (int a: currbest[p1]) for (int b: currexp[p2]) nextbest[p1 + p2].push_back(a + b);
                sort(nextbest[p1 + p2].begin(), nextbest[p1 + p2].end());
                if (nextbest[p1 + p2].size() > k) nextbest[p1 + p2].resize(k);
            }
        }
        currbest = nextbest;
        currbest.resize(i + 1);
        currbest.resize(n + 1);
    }
    for (int i = n; i >= 0; i--){
        for (int j: currbest[i]){
            cout << i << ' ' << j << '\n';
            cntr++;
            if (cntr == k) return 0;
        }
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:48:43: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]
   48 |                 if (currexp[j + 1].size() > k) currexp[j + 1].resize(k);
      |                     ~~~~~~~~~~~~~~~~~~~~~~^~~
Main.cpp:57:46: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int64_t' {aka 'long int'} [-Wsign-compare]
   57 |                 if (nextbest[p1 + p2].size() > k) nextbest[p1 + p2].resize(k);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 5054 ms 964 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5054 ms 964 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5036 ms 944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5054 ms 964 KB Time limit exceeded
2 Halted 0 ms 0 KB -