답안 #373926

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
373926 2021-03-06T06:39:42 Z i_am_noob Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
469 ms 30572 KB
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,avx512f")
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define inf 1010000000
//#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {static int cnt=0;cerr << x << endl;cnt++;if(cnt>1000) exit(0);}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 826
#endif

inline char readchar(){
    const int maxn=1000000;
    static char buf[maxn],*p=buf,*q=buf;
    if(p==q&&(q=(p=buf)+fread(buf,1,maxn,stdin))==buf) return EOF;
    else return *p++;
}
inline int readint(){
    int c=readchar(),x=0,neg=0;
    while((c<'0'||c>'9')&&c!='-'&&c!=EOF) c=readchar();
    if(c=='-') neg=1,c=readchar();
    while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^'0'),c=readchar();
    return neg?-x:x;
}

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=500005;
//i_am_noob
int n,q;
ll a[maxn],b[maxn];

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    #ifdef i_am_noob
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    freopen("output2.txt","w",stderr);
    #endif
    n=readint(),q=readint();
    rep(n) a[i]=readint();
    b[0]=1;
    rep(n) b[i+1]=(a[i]+b[i]-1)/b[i]*b[i];
    int t,x,y,mid,l,r,ans;
    while(q--){
        t=readint(),x=readint(),y=readint();
        l=0,r=n+1;
        while(l<r){
            mid=l+r>>1;
            if(-mid+t/b[mid]*b[mid]<=y) r=mid;
            else l=mid+1;
        }
        ans=-l;
        l=0,r=n+1;
        while(l<r){
            mid=l+r>>1;
            if(-mid+t/b[mid]*b[mid]<x) r=mid;
            else l=mid+1;
        }
        ans+=l;
        cout << ans << "\n";
    }
    return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:67:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   67 |             mid=l+r>>1;
      |                 ~^~
worst_reporter3.cpp:74:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   74 |             mid=l+r>>1;
      |                 ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 460 ms 12244 KB Output is correct
2 Correct 456 ms 12268 KB Output is correct
3 Correct 450 ms 12140 KB Output is correct
4 Correct 454 ms 12268 KB Output is correct
5 Correct 450 ms 12344 KB Output is correct
6 Correct 433 ms 12140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 460 ms 12244 KB Output is correct
2 Correct 456 ms 12268 KB Output is correct
3 Correct 450 ms 12140 KB Output is correct
4 Correct 454 ms 12268 KB Output is correct
5 Correct 450 ms 12344 KB Output is correct
6 Correct 433 ms 12140 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 205 ms 20716 KB Output is correct
14 Correct 199 ms 26988 KB Output is correct
15 Correct 198 ms 25572 KB Output is correct
16 Correct 200 ms 25972 KB Output is correct
17 Correct 282 ms 30188 KB Output is correct
18 Correct 281 ms 30188 KB Output is correct
19 Correct 284 ms 30572 KB Output is correct
20 Correct 282 ms 30188 KB Output is correct
21 Correct 297 ms 30316 KB Output is correct
22 Correct 288 ms 30316 KB Output is correct
23 Correct 285 ms 30316 KB Output is correct
24 Correct 297 ms 30444 KB Output is correct
25 Correct 469 ms 27756 KB Output is correct
26 Correct 448 ms 27628 KB Output is correct
27 Correct 335 ms 29932 KB Output is correct
28 Correct 340 ms 30060 KB Output is correct
29 Correct 333 ms 29676 KB Output is correct
30 Correct 344 ms 29804 KB Output is correct
31 Correct 366 ms 30060 KB Output is correct
32 Correct 326 ms 26348 KB Output is correct
33 Correct 1 ms 364 KB Output is correct