Submission #897613

#TimeUsernameProblemLanguageResultExecution timeMemory
897613mihtriii295Kas (COCI17_kas)C++17
30 / 100
65 ms2652 KiB
#include<bits/stdc++.h> #pragma GCC optimize("O2") #define ll long long #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define el cout << '\n' using namespace std; const ll N = 1e8 + 1; const ll logN = 20; const ll MOD = 1e9 + 7; int n, a[N], res, f[N], sum; int main(){ if(fopen("coci1617_r4_kas.inp", "r")){ freopen("coci1617_r4_kas.inp", "r", stdin); freopen("coci1617_r4_kas.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n; f[0] = 1; for (int i = 1; i <= n; ++i){ cin >> a[i]; sum += a[i]; } for (int i = 1; i <= n; ++i){ for (int j = 2 * sum; j >= a[i]; --j) if (f[j - a[i]] == 1) f[j] = 1; } for (int i = 2 * sum; i >= 0; --i){ if (i & 1) continue; if (f[i] == 1 && f[i / 2] == 1){ cout << i / 2 + sum - i; break; } } return 0; }

Compilation message (stderr)

kas.cpp: In function 'int main()':
kas.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen("coci1617_r4_kas.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kas.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("coci1617_r4_kas.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...