Submission #842845

#TimeUsernameProblemLanguageResultExecution timeMemory
842845_Avocado_Self Study (JOI22_ho_t2)C++14
62 / 100
231 ms11344 KiB
#include <bits/stdc++.h> #define int int64_t using namespace std; int n, m; int up(int a, int b){ return (a + (b-1))/b; } const int INF = 1e18+18; int check(int x, auto&a, auto&b){ int sum = 0; for(int i = 0; i<n; ++i){ int days = up(x, a[i]); if(sum > INF) return 0; sum += min(m, (int)days); if(days > m){ int rest = x - (m*a[i]); int extra_days = up(rest, b[i]); if(sum > INF) return 0; sum += extra_days; } } if(sum <= n*m) return 1; return 0; } int bsearch(auto&a, auto&b){ int l = -1; int r = INF; while(r-l > 1){ int x = (r+l)/2; if(check(x, a, b)) l = x; else r = x; } return l; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout); cin>>n>>m; vector<int>a(n); for(auto&u: a) cin>>u; vector<int>b(n); for(auto&u: b) cin>>u; for(int i = 0; i<n; ++i){ a[i] = max(a[i], b[i]); } cout<<bsearch(a, b); cout<<'\n'; }

Compilation message (stderr)

Main.cpp:13:18: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   13 | int check(int x, auto&a, auto&b){
      |                  ^~~~
Main.cpp:13:26: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   13 | int check(int x, auto&a, auto&b){
      |                          ^~~~
Main.cpp:32:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   32 | int bsearch(auto&a, auto&b){
      |             ^~~~
Main.cpp:32:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   32 | int bsearch(auto&a, auto&b){
      |                     ^~~~
#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...