Submission #991560

#TimeUsernameProblemLanguageResultExecution timeMemory
991560rsinventorSelf Study (JOI22_ho_t2)C++17
10 / 100
107 ms11604 KiB
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; typedef vector<int> vi; typedef vector <ll> vll; typedef vector<bool> vb; typedef vector <string> vs; typedef vector<char> vc; typedef pair<int, int> pii; typedef vector <pii> vpii; #define all(a) (a).begin(), (a).end() #define pb push_back #define endl "\n" ll n, m; ll adds(ll mid, vll& a, vll& b) { ll sum = 0; for(int i = 0; i < a.size(); i++) { if(a[i]>b[i]) { ll class_cnt = 1 + ((mid - 1) / a[i]); if (class_cnt > m) { sum += 1 + ((mid - a[i] * m - 1) / b[i]) + m; } else { sum += class_cnt; } } else { sum += 1 + ((mid-1)/b[i]); } } return sum; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; vll a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } vll b(n); for(int i = 0; i < n; i++) { cin >> b[i]; } ll l = 0; ll r = 50000000000000; while(l<r) { ll mid = l + (r - l)/2; if(adds(mid, a, b)<=n*m) { l = mid+1; } else { r = mid; } } cout << l-1 << endl; return 0; }

Compilation message (stderr)

Main.cpp: In function 'll adds(ll, vll&, vll&)':
Main.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long unsigned int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i = 0; i < a.size(); i++) {
      |                    ~~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
   42 |     for(int i = 0; i < n; i++) {
      |                    ~~^~~
Main.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'll' {aka 'long long unsigned int'} [-Wsign-compare]
   46 |     for(int i = 0; i < n; i++) {
      |                    ~~^~~
#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...