Submission #204509

#TimeUsernameProblemLanguageResultExecution timeMemory
204509theStaticMindWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
805 ms33552 KiB
#include<bits/stdc++.h> #define pb push_back #define ii pair<int,int> #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() #define INF 100000000000000000 #define modulo 1000000007 #define mod 998244353 #define int long long int using namespace std; vector<int> slow; vector<ii> mv; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; cin >> n >> q; slow.pb(1); for(int i = 0; i < n; i++){ int x; cin >> x; slow.pb(x); } mv.pb({1, 1}); for(int i = 1; i < slow.size(); i++){ int px = mv.back().first; int pt = mv.back().second; int cx = slow[i]; // if(pt > 3e9)break; int k = (cx - 1) / px + 1; mv.pb({k * px, k * pt}); assert(2e18 / k > pt); } while(q--){ int t, x, y; cin >> t >> x >> y; int l = 0, r = sz(mv) - 1, low = INF, high = -INF; while(l <= r){ int mid = (l + r) / 2; int curr = -mid + (t / mv[mid].second) * mv[mid].first; if(curr <= y){ low = mid; r = mid - 1; } else l = mid + 1; } l = 0, r = sz(mv) - 1; while(l <= r){ int mid = (l + r) / 2; int curr = -mid + (t / mv[mid].second) * mv[mid].first; if(x <= curr){ high = mid; l = mid + 1; } else r = mid - 1; } if(high < low)cout << "0\n"; else cout << high - low + 1 << "\n"; } }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int32_t main()':
worst_reporter3.cpp:28:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 1; i < slow.size(); i++){
                      ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...