제출 #1124848

#제출 시각아이디문제언어결과실행 시간메모리
1124848njoop은행 (IZhO14_bank)C++17
0 / 100
3 ms4416 KiB
#include <bits/stdc++.h> using namespace std; int cov[1000010], mon[1000010], notes[30], ppl[30], n, m; int main() { cin >> n >> m; for(int i=1; i<=n; i++) { cin >> ppl[i]; } for(int i=1; i<=m; i++) { cin >> notes[i]; } for(int i=0; i<=(1<<20); i++) { cov[i] = -1; } cov[0] = 0; for(int i=0; i<(1<<m); i++) { for(int j=0; j<m; j++) { if(i & (1 << j) == 0) continue; int pre = i & ~(1 << j); if(cov[pre] == -1) continue; if(mon[pre]+notes[j+1] < ppl[cov[pre]+1]) { cov[i] = cov[pre]; mon[i] = mon[pre]+notes[j+1]; } else if(mon[pre]+notes[j+1] == ppl[cov[pre]+1]) { cov[i] = cov[pre]+1; mon[i] = 0; } } if(cov[i] == n) { cout << "YES"; return 0; } } cout << "NO"; return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:16:16: warning: iteration 1000010 invokes undefined behavior [-Waggressive-loop-optimizations]
   16 |         cov[i] = -1;
      |         ~~~~~~~^~~~
bank.cpp:15:19: note: within this loop
   15 |     for(int i=0; i<=(1<<20); i++) {
      |                  ~^~~~~~~~~
bank.cpp:16:16: warning: 'void* __builtin_memset(void*, int, long unsigned int)' writing 4194308 bytes into a region of size 4000040 overflows the destination [-Wstringop-overflow=]
   16 |         cov[i] = -1;
      |         ~~~~~~~^~~~
bank.cpp:5:5: note: destination object 'cov' of size 4000040
    5 | int cov[1000010], mon[1000010], notes[30], ppl[30], n, m;
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...