답안 #1017950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1017950 2024-07-09T11:47:06 Z ag_1204 Intercastellar (JOI22_ho_t1) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define pb push_back
 
int pow2(int n) {
    return (n & (~(n - 1)));
}

int low(vector<int> v,int k) {
    int n=size(v);
    int lo = 0,hi = n - 1;
    while (lo < hi) {
        int mid = (lo + hi) / 2;
        if (v[mid] < k) lo = mid + 1;
        else hi = mid;
    }
    return hi;
}
 
void solve() {
    int n; cin>>n;
    int a[n];
    map<int,int> poww;
    for (int i=0;i<30;i++) {
        int k=pow(2,i);
        poww[k]=i;
    }
    vi vals(n),sums(n);
    int sum=0;
    for (int i=0;i<n;i++) {
        cin>>a[i];
        int m=pow2(a[i]);
        a[i]/=m;
        sum+=m;
        vals[i]=a[i]; sums[i]=sum;
    }
    int q; cin>>q;
    while(q--) {
        int x; cin>>x;
        int i=low(sums,x);
        cout<<vals[i]<<endl;
    }
    return;
}
 
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int tt=1; //cin>>tt;
	while(tt--) {
	    solve();
	}
	return 0;
}

Compilation message

Main.cpp: In function 'long long int low(std::vector<long long int>, long long int)':
Main.cpp:14:11: error: 'size' was not declared in this scope; did you mean 'dysize'?
   14 |     int n=size(v);
      |           ^~~~
      |           dysize