답안 #204501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
204501 2020-02-26T06:58:52 Z theStaticMind Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
770 ms 30928 KB
#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 > 1e10)break;
      	int k = (cx - 1) / px + 1;
      	mv.pb({k * px, k * pt});
      }

     	while(q--){
     		int t, x, y;
     		cin >> t >> x >> y;

     		int l = 0, r = sz(mv) - 1, low = 0, high = -1;
     		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;
     		}
     		cout << high - low + 1 << "\n";
     	}
}

Compilation message

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++){
                      ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 770 ms 30928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 424 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 770 ms 30928 KB Output isn't correct
2 Halted 0 ms 0 KB -