# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347905 | CaroLinda | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 465 ms | 21520 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x.size() )
const int MAX = 5e5+10 ;
using namespace std ;
struct Block
{
int speed, loc, tam ;
Block(int s=0, int l = 0, int t = 0 ) : speed(s), loc(l), tam(t) {}
} ;
int N , Q , T , L , R ;
int speed[MAX] ;
vector<Block> blocks ;
int main()
{
blocks.push_back(Block(1,0,1) ) ;
scanf("%d %d", &N, &Q ) ;
for(int i = 1 , d ; i <= N ; i++ )
{
scanf("%d", &d ) ;
if( d <= blocks.back().speed )
{
blocks.back().tam++ ;
continue ;
}
else
blocks.push_back( Block( ((d+blocks.back().speed-1)/blocks.back().speed)*blocks.back().speed, -i, 1) ) ;
}
for(int i = 1 ; i <= Q ; i++ )
{
scanf("%d %d %d", &T, &L, &R ) ;
int ans = 0 ;
for(auto e : blocks )
{
int a = e.loc + ( T/e.speed ) * e.speed ;
int b = a - e.tam + 1 ;
if( R < a ) a= R ;
if( L > b ) b = L ;
if( a >= b ) ans += a-b+1 ;
}
printf("%d\n", ans ) ;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |