Submission #347905

#TimeUsernameProblemLanguageResultExecution timeMemory
347905CaroLindaWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
465 ms21520 KiB
#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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...