Submission #220205

# Submission time Handle Problem Language Result Execution time Memory
220205 2020-04-07T10:27:45 Z patrikpavic2 Worst Reporter 3 (JOI18_worst_reporter3) C++17
12 / 100
15 ms 2304 KB
#include <cstdio>
#include <cstring>
#include <vector>

#define X first
#define Y second
#define PB push_back

using namespace std;

typedef long long ll;

const int N = 1e5  + 500;

ll D[N];
int n, q;

int kolko(ll T,ll L,ll R){
	ll tren = T;
	int ans = 0;
	//printf("TIME = %lld\n", T);
	for(int i = 0;i <= n;i++){
		//printf("POS[ %d ] = %lld\n", i, tren * D[i] - i);
		if(L <= tren * D[i] - i && tren * D[i] - i <= R)
			ans++;	
		if(i != n)
			tren = tren / (D[i + 1] / D[i]);
		if(!tren) break;
	}
	return ans;
}

int main(){
	scanf("%d%d", &n, &q);
	D[0] = 1;
	for(int i = 1;i <= n;i++){
		scanf("%lld", D + i);
		if(D[i] < D[i - 1])
			D[i] = D[i - 1];
		else if(D[i] % D[i - 1])
			D[i] += D[i - 1] - D[i] % D[i - 1];
	}
	for(;q--;){
		ll A, B, C; scanf("%lld%lld%lld", &A, &B, &C);
		printf("%d\n", kolko(A, B, C));
	}
	return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~
worst_reporter3.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", D + i);
   ~~~~~^~~~~~~~~~~~~~~
worst_reporter3.cpp:44:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ll A, B, C; scanf("%lld%lld%lld", &A, &B, &C);
               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 2304 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 9 ms 256 KB Output is correct
6 Correct 9 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 2304 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -