답안 #691716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
691716 2023-01-31T13:12:48 Z IUA_Hasin Intercastellar (JOI22_ho_t1) C++17
60 / 100
2000 ms 24372 KB
#include <bits/stdc++.h>

#define endl                                "\n"
#define finp                                for(int i=0; i<n; i++)
#define fknp                                for(int k=0; k<n; k++)
#define yeap                                cout<<"YES"<<endl
#define nope                                cout<<"NO"<<endl
#define inpintn                             int n; cin>>n
#define inpintarrn                          int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define inpllarrn                           long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define ll                                  long long

ll expo(ll n){
    ll count=0;
    while(n%2==0){
        count++;
        n/=2;
    }
    return count;
}

using namespace std;

int main ()
{
   ll n;
   cin>>n;
   ll arr[n];
   ll zrr[n];
   for (int i=0; i<n; i++){
    cin>>arr[i];
    zrr[i]=arr[i];
   }
   sort(zrr, zrr+n);
   ll q;
   cin>>q;
   ll brr[q];
   for (int i=0; i<q; i++){
    cin>>brr[i];
   }

   ll crr[n];
   for (int i=0; i<n; i++){
    int x=expo(arr[i]);
    int y=pow(2,x);
    crr[i]=y;
   }
   if (zrr[n-1]>8){
    for (int i=0; i<q; i++){
    ll coun=0;
    for (int j=0; j<n; j++){
        if (j==n-1){
            if (coun>=brr[i]){
                ll z=arr[n-2]/crr[n-2];
                cout << z << " ";
                break;
            } else {
                ll z=arr[n-1]/crr[n-1];
                cout << z << " ";
                break;

            }

        } else if (brr[i]>coun){
            coun+=crr[j];
        } else {
            ll z=arr[j-1]/crr[j-1];
            cout << z << " ";
            break;
        }
    }
   }
   } else {
    vector<ll> ans;
   for (int i=0; i<n; i++){
    ll a=expo(arr[i]);
    if(a==0){
        ans.push_back(arr[i]);
    } else {
        ll b=pow(2,a);
        ll c=arr[i]/b;
        for (int k=0; k<b; k++){
            ans.push_back(c);
        }
    }
   }
   for (int l=0; l<q; l++){
    ll d=ans[brr[l]-1];
    cout << d << " ";
   }
   }




    return 0;


}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 71 ms 9340 KB Output is correct
4 Correct 85 ms 4872 KB Output is correct
5 Correct 111 ms 12216 KB Output is correct
6 Correct 82 ms 14228 KB Output is correct
7 Correct 119 ms 16076 KB Output is correct
8 Correct 146 ms 24372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 71 ms 9340 KB Output is correct
4 Correct 85 ms 4872 KB Output is correct
5 Correct 111 ms 12216 KB Output is correct
6 Correct 82 ms 14228 KB Output is correct
7 Correct 119 ms 16076 KB Output is correct
8 Correct 146 ms 24372 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1118 ms 4180 KB Output is correct
24 Execution timed out 2074 ms 6812 KB Time limit exceeded
25 Halted 0 ms 0 KB -