Submission #530944

# Submission time Handle Problem Language Result Execution time Memory
530944 2022-02-27T07:34:07 Z N1NT3NDO Akcija (COCI21_akcija) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) (int)x.size()
#define fi first
#define sd second
#define all(x) x.begin(), x.end()
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

//#define int long long

const ll inf = (ll)1e15;
const int N = 2000;
ll w[N], dp[N][N][N];
ll n, k, d[N], nom[N];

vector< pair<ll, ll> > ans;

bool cmp(int i, int j)
{
    return d[i] < d[j];
}

bool cmp2(pair<ll, ll> a, pair<ll, ll> b)
{

    if (a.fi < b.fi) return 0;
  	else if (a.fi == b.fi && a.sd < b.sd) return 0;
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> w[i] >> d[i];
        nom[i] = i;
    }

    sort(nom + 1, nom + n + 1, cmp);
    for(int i = 0; i <= n; i++)
      for(int j = 0; j <= n; j++)
        for(int c = 0; c <= n; c++)
          dp[i][j][c] = inf;

    for(int i = 1; i <= n; i++) cout << nom[i] << endl;
    cout << endl;

    for(int i = 0; i <= n; i++) dp[i][0][0] = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= i; j++)
        {
            for(int time = 0; time <= n; time++)
            {
                dp[i][j][time] = min(dp[i][j][time], dp[i - 1][j][time]);
                if (time < d[nom[i]] && dp[i][j][time + 1] > dp[i - 1][j - 1][time] + w[nom[i]])
                {
                    dp[i][j][time + 1] = dp[i - 1][j - 1][time] + w[nom[i]];
                }
            }
        }
    }

    for(int i = 0; i <= n; i++)
      for(int j = 0; j <= n; j++)
        for(int time = 0; time <= n; time++)
        {
            //cout << j << ' ' << dp[i][j][time] << endl;
            if (dp[i][j][time] == inf)
              ans.pb({0, 0});
            else ans.pb({j, dp[i][j][time]});
        }

    stable_sort(ans.begin(), ans.end(), cmp2);

    for(int i = 0; i < k; i++)
    {
        cout << ans[i].fi << ' ' << ans[i].sd << '\n';
    }
}

Compilation message

/tmp/ccDYpGGl.o: in function `main':
Main.cpp:(.text.startup+0x3a): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x41): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x4c): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccDYpGGl.o
Main.cpp:(.text.startup+0x8a): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x23f): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x291): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x298): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x2c5): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
Main.cpp:(.text.startup+0x34d): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccDYpGGl.o
Main.cpp:(.text.startup+0x58d): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status