제출 #631303

#제출 시각아이디문제언어결과실행 시간메모리
631303mouseyBrunhilda’s Birthday (BOI13_brunhilda)C++14
48.73 / 100
1043 ms79556 KiB
#include <bits/stdc++.h> #define ll long long #define vll vector<ll> #define vllp vector<pair<ll, ll> > #define pdb pair <double, double> #define YES cout<<"YES" #define NO cout<<"NO" #define endl cout<<"\n" #define vv vector <vector <ll> > #define pll pair <ll, ll> #define mp make_pair #define pb push_back #define f first #define s second using namespace std; const ll mod=1e9+7; const ll modx=998244353; const double eps=1e-9; const ll INF=INT_MAX; const ll INFINF=LLONG_MAX; const ll N=1e5, MAXN=1e7; ll n, q; ll a[N+5]; ll ans[MAXN+5]; ll product=1; void input() { cin >> n >> q; for(int i = 1; i <= n; i++) { cin >> a[i]; product*=a[i]; if(product>=MAXN) product=MAXN; } } void solve() { ll cur=n; for(int i = 2; i <= MAXN; i++) { ans[i]=INFINF; if(i>=product) continue; if(i<a[n]) { ans[i]=1; continue; } for(int j = n; j >= 1 && j >= n-12; j--) { if(i%a[j]) ans[i]=min(ans[i], ans[i-i%a[j]]+1); } for(int j = n-13; j >= 1; j--) { if(i%a[j]) { ans[i]=min(ans[i], ans[i-i%a[j]]+1); break; } } } while(q--) { ll x; cin >> x; if(ans[x]==INFINF) cout << "oo"; else cout << ans[x]; endl; } } int main() { // auto start_time = chrono::high_resolution_clock::now(); // freopen("test.txt", "r", stdin); // freopen("out.txt", "w", stdout); ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr); input(); solve(); // auto end_time = chrono::high_resolution_clock::now(); // double duration = chrono::duration_cast<chrono::milliseconds>(end_time - start_time).count(); // cout << "\n[ " << duration << " ms ]\n"; }

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

brunhilda.cpp: In function 'void solve()':
brunhilda.cpp:41:5: warning: unused variable 'cur' [-Wunused-variable]
   41 |  ll cur=n;
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...