Submission #897604

# Submission time Handle Problem Language Result Execution time Memory
897604 2024-01-03T13:22:24 Z mihtriii295 Kas (COCI17_kas) C++17
0 / 100
38 ms 2652 KB
#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 = 3e5 + 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] = 2;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 1; i <= n; ++i){
        for (int j = sum; j >= a[i]; --j){
            if (f[j - a[i]] > 0)
                f[j]++;
        }
    }
    for (int i = sum; i >= 0; --i)
        if (f[i] >= 2){
            cout << i;
            break;
        }
    return 0;
}

Compilation message

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 time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 2520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -