Submission #8935245


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
const int N=(1<<18);
int n, a[N+10];
pair<int,int> f[N+10];
inline void up(pair<int,int> &a,pair<int,int> b){
    if (b.second>=a.first){
        a=b;
    }
    else if (b.first>=a.first){
        a.second=a.first;
        a.first=b.first;
    }
    else if (b.first<a.first && b.first>=a.second){
        a.second=b.first;
    }
}
int main(){
    cin>>n;
    for (int i=0;i<(1<<n);++i){
        scanf("%d", &a[i]);
        f[i].first=a[i];
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<(1<<n);j++){
            if (j&(1<<i)) up(f[j], f[j^(1<<i)]);
        }
    }
    int ans=0;
    for (int i=1;i<(1<<n);++i){
        ans=max(ans, f[i].first+f[i].second);
        printf("%d\n", ans);
    }
}

Submission Info

Submission Time
Task C - Linear Approximation
User Dbenyong
Language C++14 (GCC 5.4.1)
Score 0
Code Size 783 Byte
Status WA
Exec Time 2103 ms
Memory 3072 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
WA × 4
WA × 17
TLE × 2
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt WA 1 ms 256 KB
sample_02.txt WA 1 ms 256 KB
sample_03.txt WA 1 ms 256 KB
sample_04.txt WA 1 ms 256 KB
subtask_1_01.txt WA 1 ms 256 KB
subtask_1_02.txt WA 34 ms 256 KB
subtask_1_03.txt WA 8 ms 256 KB
subtask_1_04.txt TLE 2103 ms 1664 KB
subtask_1_05.txt WA 3 ms 256 KB
subtask_1_06.txt TLE 2103 ms 3072 KB
subtask_1_07.txt WA 1 ms 256 KB
subtask_1_08.txt WA 1 ms 256 KB
subtask_1_09.txt WA 1 ms 256 KB
subtask_1_10.txt WA 1 ms 256 KB
subtask_1_11.txt WA 1 ms 256 KB