結果
問題 | No.2329 Nafmo、イカサマをする |
ユーザー | 👑 Nachia |
提出日時 | 2023-05-28 14:20:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,249 bytes |
コンパイル時間 | 648 ms |
コンパイル使用メモリ | 71,112 KB |
実行使用メモリ | 10,384 KB |
最終ジャッジ日時 | 2023-08-27 09:32:17 |
合計ジャッジ時間 | 2,328 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 3 ms
9,536 KB |
testcase_02 | AC | 3 ms
9,500 KB |
testcase_03 | AC | 3 ms
9,804 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 3 ms
9,512 KB |
testcase_07 | AC | 4 ms
9,544 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 3 ms
9,548 KB |
testcase_15 | AC | 3 ms
9,504 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 3 ms
9,548 KB |
testcase_25 | WA | - |
testcase_26 | AC | 3 ms
9,512 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 3 ms
9,744 KB |
testcase_32 | AC | 3 ms
9,676 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 3 ms
9,512 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:38:45: 警告: iteration 65536 invokes undefined behavior [-Waggressive-loop-optimizations] 38 | for(int i=0; i<1<<19; i++) sortcnt23[i] = 0; | ~~~~~~~~~~~~~^~~ main.cpp:38:19: 備考: within this loop 38 | for(int i=0; i<1<<19; i++) sortcnt23[i] = 0; | ~^~~~~~ main.cpp:38:45: 警告: ‘void* __builtin_memset(void*, int, long unsigned int)’ writing 2097152 bytes into a region of size 262144 overflows the destination [-Wstringop-overflow=] 38 | for(int i=0; i<1<<19; i++) sortcnt23[i] = 0; | ~~~~~~~~~~~~~^~~ main.cpp:8:5: 備考: destination object ‘sortcnt23’ of size 262144 8 | u32 sortcnt23[1<<16] = {}; | ^~~~~~~~~
ソースコード
#include <iostream> using namespace std; using u32 = unsigned int; u32 A1[1<<10]; u32 A2[1<<19]; u32 sortcnt23[1<<16] = {}; u32 A3[1<<19]; u32 B2[1<<19]; u32 B3[1<<19]; int main() { using namespace std; u32 N,M,K; cin >> N >> M >> K; for(u32 i=0; i<N; i++) cin >> A1[i]; A1[N] = 0; N++; u32 A2p = 0; if(K/2 >= 0) A2[A2p++] = 0; if(K/2 >= 1) for(u32 i=0; i<N; i++) A2[A2p++] = A1[i]; if(K/2 >= 2) for(u32 i=0; i<N; i++) for(u32 j=i; j<N; j++) A2[A2p++] = A1[i] + A1[j]; if(K/2 >= 3) for(u32 i=0; i<N; i++) for(u32 j=i; j<N; j++) for(u32 k=j; k<N; k++) A2[A2p++] = A1[i] + A1[j] + A1[k]; u32 B2p = 0; if((K+1)/2 >= 0) B2[B2p++] = 0; if((K+1)/2 >= 1) for(u32 i=0; i<N; i++) B2[B2p++] = A1[i]; if((K+1)/2 >= 2) for(u32 i=0; i<N; i++) for(u32 j=i; j<N; j++) B2[B2p++] = A1[i] + A1[j]; if((K+1)/2 >= 3) for(u32 i=0; i<N; i++) for(u32 j=i; j<N; j++) for(u32 k=j; k<N; k++) B2[B2p++] = A1[i] + A1[j] + A1[k]; for(u32 i=0; i<A2p; i++) sortcnt23[(~A2[i])&65535]++; for(u32 i=1; i<(1<<16); i++) sortcnt23[i] += sortcnt23[i-1]; for(u32 i=0; i<A2p; i++) A3[--sortcnt23[(~A2[i])&65535]] = A2[i]; for(u32 i=0; i<(1<<16); i++) sortcnt23[i] = 0; for(u32 i=0; i<A2p; i++) sortcnt23[A3[i]>>16]++; for(u32 i=1; i<(1<<16); i++) sortcnt23[i] += sortcnt23[i-1]; for(u32 i=0; i<A2p; i++) A2[--sortcnt23[A3[i]>>16]] = A3[i]; for(int i=0; i<1<<19; i++) sortcnt23[i] = 0; for(u32 i=0; i<B2p; i++) sortcnt23[(~B2[i])&65535]++; for(u32 i=1; i<(1<<16); i++) sortcnt23[i] += sortcnt23[i-1]; for(u32 i=0; i<B2p; i++) B3[--sortcnt23[(~B2[i])&65535]] = B2[i]; for(u32 i=0; i<(1<<16); i++) sortcnt23[i] = 0; for(u32 i=0; i<B2p; i++) sortcnt23[B3[i]>>16]++; for(u32 i=1; i<(1<<16); i++) sortcnt23[i] += sortcnt23[i-1]; for(u32 i=0; i<B2p; i++) B2[--sortcnt23[B3[i]>>16]] = B3[i]; u32 ans = 0; u32 q = B2p-1; while(B2[q] > M) q--; for(u32 p=0; p<q; p++){ while(A2[p]+B2[q] > M) q--; if(ans < A2[p] + B2[q]) ans = A2[p] + B2[q]; } cout << ans << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;