Submission #126774

#TimeUsernameProblemLanguageResultExecution timeMemory
126774abacabaKas (COCI17_kas)C++14
50 / 100
236 ms612 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const int N = 1e3 + 15; int n, a[N], summ; int ans = inf; int main() { scanf("%d", &n); for(int i = 0; i < n; ++i) { scanf("%d", &a[i]); summ += a[i]; } for(int mask = 0; mask < (1 << n); ++mask) { int sum = 0; for(int i = 0; i < n; ++i) if((1 << i) & mask) sum += a[i]; for(int s = mask; s; s = ((s - 1) & mask)) { int now = 0; for(int i = 0; i < n; ++i) if((1 << i) & s) now += a[i]; if(now + now == sum) ans = min(ans, summ - sum); } } cout << ans + (summ - ans) / 2; return 0; }

Compilation message (stderr)

kas.cpp: In function 'int main()':
kas.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
kas.cpp:12: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...