Submission #347905

# Submission time Handle Problem Language Result Execution time Memory
347905 2021-01-13T17:57:20 Z CaroLinda Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
465 ms 21520 KB
#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

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |  scanf("%d %d", &N, &Q ) ;
      |  ~~~~~^~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |     scanf("%d", &d ) ;
      |     ~~~~~^~~~~~~~~~~
worst_reporter3.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   44 |   scanf("%d %d %d", &T, &L, &R ) ;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 306 ms 18796 KB Output is correct
2 Correct 312 ms 18796 KB Output is correct
3 Correct 312 ms 18796 KB Output is correct
4 Correct 316 ms 18924 KB Output is correct
5 Correct 310 ms 19052 KB Output is correct
6 Correct 308 ms 18796 KB Output is correct
# Verdict Execution time Memory 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 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 306 ms 18796 KB Output is correct
2 Correct 312 ms 18796 KB Output is correct
3 Correct 312 ms 18796 KB Output is correct
4 Correct 316 ms 18924 KB Output is correct
5 Correct 310 ms 19052 KB Output is correct
6 Correct 308 ms 18796 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 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 325 ms 17516 KB Output is correct
14 Correct 333 ms 17900 KB Output is correct
15 Correct 303 ms 16664 KB Output is correct
16 Correct 314 ms 17132 KB Output is correct
17 Correct 415 ms 21484 KB Output is correct
18 Correct 407 ms 21384 KB Output is correct
19 Correct 419 ms 21484 KB Output is correct
20 Correct 419 ms 21484 KB Output is correct
21 Correct 401 ms 21356 KB Output is correct
22 Correct 442 ms 21484 KB Output is correct
23 Correct 406 ms 21472 KB Output is correct
24 Correct 408 ms 21520 KB Output is correct
25 Correct 354 ms 18880 KB Output is correct
26 Correct 316 ms 18796 KB Output is correct
27 Correct 424 ms 21056 KB Output is correct
28 Correct 439 ms 21300 KB Output is correct
29 Correct 447 ms 20828 KB Output is correct
30 Correct 465 ms 20972 KB Output is correct
31 Correct 442 ms 21180 KB Output is correct
32 Correct 313 ms 17492 KB Output is correct
33 Correct 1 ms 364 KB Output is correct