제출 #1017640

#제출 시각아이디문제언어결과실행 시간메모리
1017640FIFI_cppIntercastellar (JOI22_ho_t1)C++17
0 / 100
0 ms348 KiB
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <deque> #include <fstream> #include <iterator> #include <set> #include <map> #include <unordered_map> #include <iomanip> #include <cctype> #include <string> #include <cassert> #include <set> #include <bitset> #include <unordered_set> using ll = int64_t; #define pb push_back #define all(a) a.begin(),a.end() #define ppi pair<pair<int,int>,int> #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); //#define int int64_t // xcode cant include bits/stdc++.h using namespace std; //ifstream fin ("sleepy.in"); //ofstream fout ("sleepy.out"); /* /\_/\ * (= ._.) * / > \> */ // encouraging cat const int INF = 10000000000000000; const int mod = 1000000007; int32_t main() { int n; cin >> n; vector<int> a(n); for (int i = 0;i < n;i++) { cin >> a[i]; } vector<int> pref(n,0); vector<int> val(n,0); int s = 0; for (int i = 0;i < n;i++) { int lo = 0,hi = 30,mid = (lo + hi) / 2; int prev = -1; while (lo < hi) { mid = (lo + hi) / 2; if (mid == prev) break; prev = mid; if (a[i] % (int)pow(2,mid) == 0) { lo = mid; } else { hi = mid - 1; } } mid = (lo + hi) / 2; if (a[i] % (int)pow(2,mid + 1) == 0) mid++; val[i] = a[i] / pow(2,mid); //cout << pow(2,mid) << '\n'; s += pow(2,mid); pref[i] = s; } int q; cin >> q; while (q--) { int x; cin >> x; int lo = 0,hi = n - 1,mid = (lo + hi) / 2; int prev = -1; while (lo < hi) { mid = (lo + hi) / 2; if (prev == mid) break; prev = mid; if (pref[mid] <= x) { lo = mid; } else { hi = mid - 1; } } mid = (lo + hi) / 2; if (mid < n - 1 && pref[mid + 1] <= x) mid++; if (pref[mid] == x) cout << val[mid] << '\n'; else cout << val[mid + 1] << '\n'; } return 0; }

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

Main.cpp:32:9: warning: "/*" within comment [-Wcomment]
   32 | /*   /\_/\
      |          
Main.cpp:37:17: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000000000' to '1874919424' [-Woverflow]
   37 | const int INF = 10000000000000000;
      |                 ^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...