제출 #1073939

#제출 시각아이디문제언어결과실행 시간메모리
1073939deera휴가 (IOI14_holiday)C++17
7 / 100
5074 ms1628 KiB
#include <bits/stdc++.h>
using namespace std;

long long findMaxAttraction(int n, int start, int d, int attration[]) {
    if (n <= 20) {
        // iterate over all the subtasks
        long long max_ans = 0;
        long long ans = 0;
        for (int32_t i = 0; i < (1 << n); i++) {
            int len = 32 - (__builtin_clz(i) + __builtin_ctz(i)) - 1;
            int a = __builtin_ctz(i);
            int b = 31 - __builtin_clz(i);
            int cost = __builtin_popcount(i) + len + min(abs(a - start), abs(b - start));
            
            // if (i == 30) {
            //     for (int j = 0; j < n; j++) {
            //         cerr << ((i & (1 << j)) ? 1 : 0) << " ";
            //     }
            //     cerr << endl;
            //     cerr << cost << endl;
            //     cerr << a << " " << b << endl;
            // }

            if (cost > d) continue;
            for (int j = 0; j < n; j++) {
                if (i & (1 << j)) {
                    ans += attration[j];
                }
            }

            max_ans = max(max_ans, ans);
            ans = 0;
        }

        return max_ans;
    }
}

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

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...