Submission #584807

#TimeUsernameProblemLanguageResultExecution timeMemory
584807jack715Holiday (IOI14_holiday)C++14
0 / 100
5075 ms1492 KiB
#include"holiday.h" #include <bits/stdc++.h> #define ll long long #define pb push_back #define pp pop_back #define mp make_pair #define bb back #define ff first #define ss second using namespace std; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { int ans = 0; for (int state = 1; state < (1 << n); state++) { int l = -1, r, cnt = 0, now = 0; for (int i = 0; i < n; i++) { if (state & (1 << i)) { if (l == -1) l = i; r = i; cnt++; now += attraction[i]; } } if (min(abs(start-l)*2+abs(start-r), abs(start-r)*2+abs(start-l))+cnt <= d) ans = max(ans, now); } return ans; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:26:55: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |         if (min(abs(start-l)*2+abs(start-r), abs(start-r)*2+abs(start-l))+cnt <= d)
      |                                                  ~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...