제출 #1336933

#제출 시각아이디문제언어결과실행 시간메모리
1336933Nipphitch만두 (JOI14_ho_t2)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
const int M=505;
const int N=5e6+5;

int n,m,c[M],e[M],p[N],dp1[N],dp2[M][N],ans;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i=1;i<=n;i++) cin >> p[i];
    sort(p+1,p+1+n,greater <int>());
    for(int i=1;i<=N;i++) dp1[i]=dp1[i-1]+p[i];
    for(int i=0;i<=m;i++) for(int j=1;j<=N;j++) dp2[i][j]=INT_MAX/2;
    for(int i=1;i<=m;i++){
        cin >> c[i] >> e[i];
        for(int j=N;j>=1;j--){
            dp2[i][j]=dp2[i-1][j];
            if(j-c[i]<0) continue;
            dp2[i][j]=min(dp2[i][j],dp2[i-1][j-c[i]]+e[i]);
        }
    }
    for(int i=1;i<=N;i++) ans=max(ans,dp1[i]-dp2[m][i]);
    //for(int i=0;i<=n*2;i++) cout << dp2[m][i] << " ";
    cout << ans;
}

컴파일 시 표준 에러 (stderr) 메시지

2014_ho_t2.cpp: In function 'int main()':
2014_ho_t2.cpp:15:46: warning: iteration 5000004 invokes undefined behavior [-Waggressive-loop-optimizations]
   15 |     for(int i=1;i<=N;i++) dp1[i]=dp1[i-1]+p[i];
      |                                           ~~~^
2014_ho_t2.cpp:15:18: note: within this loop
   15 |     for(int i=1;i<=N;i++) dp1[i]=dp1[i-1]+p[i];
      |                 ~^~~
2014_ho_t2.cpp:25:44: warning: iteration 5000004 invokes undefined behavior [-Waggressive-loop-optimizations]
   25 |     for(int i=1;i<=N;i++) ans=max(ans,dp1[i]-dp2[m][i]);
      |                                       ~~~~~^
2014_ho_t2.cpp:25:18: note: within this loop
   25 |     for(int i=1;i<=N;i++) ans=max(ans,dp1[i]-dp2[m][i]);
      |                 ~^~~
2014_ho_t2.cpp:16:58: warning: iteration 5000004 invokes undefined behavior [-Waggressive-loop-optimizations]
   16 |     for(int i=0;i<=m;i++) for(int j=1;j<=N;j++) dp2[i][j]=INT_MAX/2;
      |                                                 ~~~~~~~~~^~~~~~~~~~
2014_ho_t2.cpp:16:40: note: within this loop
   16 |     for(int i=0;i<=m;i++) for(int j=1;j<=N;j++) dp2[i][j]=INT_MAX/2;
      |                                       ~^~~
/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+0x5f): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x66): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0xab): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0xc8): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0xe1): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0xf4): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cin_sync' defined in .bss._ZN14__gnu_internal12buf_cin_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x101): additional relocation overflows omitted from the output
(.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