제출 #938010

#제출 시각아이디문제언어결과실행 시간메모리
938010LitusianoSelf Study (JOI22_ho_t2)C++17
25 / 100
266 ms7512 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" vector<pair<int,int>> v; int n,m; bool check(int mid){ vector<int> need(n,0); int left = 0; int tot = 0; for(int i = 0; i<n && tot <= n*m; i++){ int z = max(v[i].first, v[i].second); // a la clase i, estudio o hi vaig int k = (mid+z-1)/z; // numero de veces que tengo que estudiar o ir if(k >= m) tot+=m, need[i] = mid-m * z,tot += (need[i] + v[i].second - 1)/v[i].second; // quan em falta per aprobar else tot+=k; // classes que mhan sobrat } return tot<=n*m; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; v.assign(n,{0,0}); for(auto& x : v) cin>>x.first; //a for(auto& x : v) cin>>x.second; //b int l = 0; int r = 1e18+6; while(r > l+1){ int mid = (l+r)/2; if(check(mid)) l = mid; else r = mid; } cout<<l<<endl; }

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

Main.cpp: In function 'bool check(long long int)':
Main.cpp:10:6: warning: unused variable 'left' [-Wunused-variable]
   10 |  int left = 0; int tot = 0;
      |      ^~~~
#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...