Submission #1273804

#TimeUsernameProblemLanguageResultExecution timeMemory
1273804mahersefoCloud Computing (CEOI18_clo)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define ll long long
#define all(a) (a).begin() , (a).end()
#define endl '\n'
using namespace std;
void readFromFile(string input = "input.txt",string output="output.txt") {
    #ifndef ONLINE_JUDGE
        freopen(input.c_str(),"r",stdin);
        freopen(output.c_str(),"w",stdout);
    #endif
}
const int N = 2e3+1;
#define ty array<int,4>
ty a[2*N];
int n,m,t;
ll memo[2*N][50*N];
bool vis[2*N][50*N];
ll dp(int i,int core) {
//    cout << i << ' ' << core << ' ' << a[i][3] << endl;
    if(i == t) {
        return core ? -1e18 : 0;
    }
    ll &ret = memo[i][core];
    if(vis[i][core]) {
        return ret;
    }
    vis[i][core] = 1;
    ret = dp(i+1 , core);
    if(a[i][3] && core) {
        ret = max(ret , dp(i+1 , max(0 , core-a[i][0])) - a[i][2]);
    }
    if(!a[i][3]) {
        ret = max(ret , dp(i+1 , core + a[i][0]) + a[i][2]);
    }
    return ret;
}
void solve() {
    cin >> n;
    for(int i = 0 ; i < n ; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
        a[i][3] = 1;
    }
    cin >> m;
    for(int i = n ; i < m+n ; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
        a[i][3] = 0;
    }
    t = n+m;
    sort(a,a+t,[&](ty x,ty y) {
        if(x[1] != y[1]) return x[1] < y[1];
        return x[3] < y[3];
    });
//    for(int i = 0 ; i < t ; i++) {
//        cout << a[i][0] << ' ' << a[i][1] << ' ' << a[i][2] << ' ' << a[i][3] << endl;
//    }
    cout << dp(0,0) << endl;
}
int32_t main() {
    readFromFile();
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
//    cin >> t;
    for(int i = 0 ; i < t ; i++) {
        solve();
    }
}

Compilation message (stderr)

clo.cpp: In function 'void readFromFile(std::string, std::string)':
clo.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(input.c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen(output.c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cc7AXlxU.o: in function `dp(int, int)':
clo.cpp:(.text+0x586): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/cc7AXlxU.o
clo.cpp:(.text+0x5ee): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc7AXlxU.o
/tmp/cc7AXlxU.o: in function `solve()':
clo.cpp:(.text+0x6a9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc7AXlxU.o
clo.cpp:(.text+0x6ba): 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/13/libstdc++.a(globals_io.o)
clo.cpp:(.text+0x6c5): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc7AXlxU.o
clo.cpp:(.text+0x6e4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc7AXlxU.o
clo.cpp:(.text+0x725): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc7AXlxU.o
clo.cpp:(.text+0x72e): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc7AXlxU.o
clo.cpp:(.text+0x73d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc7AXlxU.o
clo.cpp:(.text+0x743): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc7AXlxU.o
clo.cpp:(.text+0x755): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1f): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1ed): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x252): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2bc): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x316): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x50f): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x57d): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f0): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x654): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status