제출 #106370

#제출 시각아이디문제언어결과실행 시간메모리
106370abilBali Sculptures (APIO15_sculpture)C++14
9 / 100
1070 ms512 KiB
#include <bits/stdc++.h>
#define int long long
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)
#define pi pair < int, int >

using namespace std;

const long long INF = (int)1e18 + 7;
const int N = (int)2007;
const int mod = 1000000007;

int n, a, b, ans = INF, arr[N];

void solve(int pos,int sum, int an, int g){
      if(pos - 1 == n){
            if(g >= a && g <= b){
                  ans = min(ans,(an | sum));
            }
            return;
      }
      solve(pos + 1, arr[pos], (an | sum), g + 1);
      solve(pos + 1, (arr[pos] + sum ), an, g);
}
main(){
      cin >> n >> a >> b;
      for(int i = 1;i <= n; i++){
            Scan(arr[i]);
      }
      solve(2,arr[1], 0 ,1);
      cout << ans;
}
/*
6 1 3
8 1 2 1 5 4
*/

컴파일 시 표준 에러 (stderr) 메시지

sculpture.cpp:31:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:9:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 #define Scan(a) scanf ("%I64d", &a)
                                 ~~^~
 #define scan(a) scanf ("%d", &a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 #define pi pair < int, int >
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      
 
 ~                                  
 using namespace std;
 ~~~~~~~~~~~~~~~~~~~~~              
 
 ~                                  
 const long long INF = (int)1e18 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 const int N = (int)2007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~          
 const int mod = 1000000007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 
 ~                                  
 int n, a, b, ans = INF, arr[N];
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
 
 ~                                  
 void solve(int pos,int sum, int an, int g){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(pos - 1 == n){
       ~~~~~~~~~~~~~~~~~~           
             if(g >= a && g <= b){
             ~~~~~~~~~~~~~~~~~~~~~~ 
                   ans = min(ans,(an | sum));
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
             }
             ~~                     
             return;
             ~~~~~~~~               
       }
       ~~                           
       solve(pos + 1, arr[pos], (an | sum), g + 1);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       solve(pos + 1, (arr[pos] + sum ), an, g);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 }
 ~~                                 
 main(){
 ~~~~~~~~                           
       cin >> n >> a >> b;
       ~~~~~~~~~~~~~~~~~~~~         
       for(int i = 1;i <= n; i++){
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
             Scan(arr[i]);
             ~~~~~~~~~~~            
sculpture.cpp:34:13: note: in expansion of macro 'Scan'
             Scan(arr[i]);
             ^~~~
sculpture.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define Scan(a) scanf ("%I64d", &a)
                 ~~~~~~^~~~~~~~~~~~~
sculpture.cpp:34:13: note: in expansion of macro 'Scan'
             Scan(arr[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...