답안 #45695

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45695 2018-04-16T03:46:51 Z mirbek01 Bali Sculptures (APIO15_sculpture) C++17
0 / 100
10 ms 872 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 2;

int n, ar[N], a, b;
long long ans = 1e18;

int main(){
      cin >> n >> a >> b;

      for(int i = 0; i < n; i ++)
            cin >> ar[i];
      if(n > 20) return 0;
      for(int mask = 0; mask < (1 << n); mask ++){
            int last = -1, cnt = 0;
            for(int i = 0; i < n; i ++){
                  int bit = (1 << i) & mask;
                  if(bit != last) cnt ++;
                  last = bit;
            }
            if(a <= cnt && cnt <= b){
                  long long res = 0, sum = 0;
                  last = -1;
                  for(int i = 0; i < n; i ++){
                        int bit = (1 << i) & mask;
                        if(bit != last){
                              res |= sum;
                              sum = 0;
                        }
                        sum += ar[i];
                        last = bit;
                  }
                  res |= sum;
//                  if(res == 21){
//                        for(int i = 0; i < n; i ++){
//                              int bit = (1 << i) & mask;
//                              if(bit)
//                                    cout << 1;
//                              else
//                                    cout << 0;
//                        }
//                        cout << endl;
//                        return 0;
//                  }
                  ans = min(ans, res);
            }
      }

      cout << ans << endl;
}
/**
6 1 3
8 1 2 1 5 4
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 4 ms 668 KB Output is correct
7 Incorrect 6 ms 668 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 668 KB Output is correct
2 Correct 2 ms 668 KB Output is correct
3 Correct 2 ms 668 KB Output is correct
4 Correct 2 ms 696 KB Output is correct
5 Correct 2 ms 704 KB Output is correct
6 Correct 4 ms 716 KB Output is correct
7 Incorrect 10 ms 728 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 728 KB Output is correct
2 Correct 2 ms 728 KB Output is correct
3 Correct 2 ms 728 KB Output is correct
4 Correct 2 ms 728 KB Output is correct
5 Correct 2 ms 756 KB Output is correct
6 Correct 4 ms 756 KB Output is correct
7 Incorrect 7 ms 800 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 808 KB Output is correct
2 Correct 2 ms 808 KB Output is correct
3 Correct 2 ms 808 KB Output is correct
4 Correct 2 ms 808 KB Output is correct
5 Correct 2 ms 808 KB Output is correct
6 Correct 4 ms 832 KB Output is correct
7 Incorrect 6 ms 832 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 832 KB Output is correct
2 Correct 2 ms 832 KB Output is correct
3 Correct 2 ms 832 KB Output is correct
4 Correct 2 ms 832 KB Output is correct
5 Correct 2 ms 832 KB Output is correct
6 Correct 4 ms 868 KB Output is correct
7 Incorrect 10 ms 872 KB Output isn't correct
8 Halted 0 ms 0 KB -