Submission #126784

#TimeUsernameProblemLanguageResultExecution timeMemory
126784abacabaKas (COCI17_kas)C++14
0 / 100
12 ms5880 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const int M = 1e5 + 15; const int N = 5e2 + 15; int n, a[N], summ, ans = inf; bitset <M> dp1, dp2[N]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d", &a[i]); summ += a[i]; } for(int i = n; i; --i) { dp2[i] |= (dp2[i + 1] << a[i]); dp2[i][a[i]] = 1; } for(int i = 1; i <= n; ++i) { dp1 |= (dp1 << a[i]); dp1[a[i]] = 1; bitset <M> temp = (dp1 & dp2[i + 1]); for(int j = temp._Find_first(); j < M; j = temp._Find_next(j)) ans = min(ans, summ - (j << 1)); } cout << ans + (summ - ans) / 2; return 0; }

Compilation message (stderr)

kas.cpp: In function 'int main()':
kas.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
kas.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...