Submission #83444

# Submission time Handle Problem Language Result Execution time Memory
83444 2018-11-07T16:52:03 Z tincamatei Worst Reporter 3 (JOI18_worst_reporter3) C++14
19 / 100
1022 ms 93692 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 500000;
int d[1+MAX_N];
int per[1+MAX_N], jump[1+MAX_N];

int poz(int i, int t) {
	return -i + t / per[i] * jump[i];
}

int binsrc(int n, int t, int val) {
	int st = -1, dr = n + 1;
	while(dr - st > 1) {
		int mid = (st + dr) / 2;
		if(poz(mid, t) <= val)
			dr = mid;
		else
			st = mid;
	}
	return dr;
}

int main() {
#ifdef HOME
	FILE *fin = fopen("input.in", "r");
	FILE *fout = fopen("output.out", "w");
#else
	FILE *fin = stdin;
	FILE *fout = stdout;
#endif

	int n, q, t, l, r;
	fscanf(fin, "%d%d", &n, &q);
	per[0] = jump[0] = 1;
	for(int i = 1; i <= n; ++i) {
		fscanf(fin, "%d", &d[i]);
		per[i] = (d[i] + jump[i - 1] - 1) / jump[i - 1];
		jump[i] = jump[i - 1] * per[i];
		per[i] = per[i - 1] * per[i];
	}

	for(int i = 0; i < q; ++i) {
		fscanf(fin, "%d%d%d", &t, &l, &r);
		int a = binsrc(n, t, r), b = binsrc(n, t, l - 1);
		fprintf(fout, "%d\n", b - a);
	}

#ifdef HOME
	fclose(fin);
	fclose(fout);
#endif
	return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:35:8: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fscanf(fin, "%d%d", &n, &q);
  ~~~~~~^~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:38:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   fscanf(fin, "%d", &d[i]);
   ~~~~~~^~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:45:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   fscanf(fin, "%d%d%d", &t, &l, &r);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 979 ms 24600 KB Output is correct
2 Correct 992 ms 40180 KB Output is correct
3 Correct 964 ms 55636 KB Output is correct
4 Correct 1022 ms 71104 KB Output is correct
5 Correct 971 ms 86712 KB Output is correct
6 Correct 982 ms 93692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 93692 KB Output is correct
2 Correct 3 ms 93692 KB Output is correct
3 Correct 3 ms 93692 KB Output is correct
4 Correct 3 ms 93692 KB Output is correct
5 Correct 3 ms 93692 KB Output is correct
6 Correct 3 ms 93692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 979 ms 24600 KB Output is correct
2 Correct 992 ms 40180 KB Output is correct
3 Correct 964 ms 55636 KB Output is correct
4 Correct 1022 ms 71104 KB Output is correct
5 Correct 971 ms 86712 KB Output is correct
6 Correct 982 ms 93692 KB Output is correct
7 Correct 4 ms 93692 KB Output is correct
8 Correct 3 ms 93692 KB Output is correct
9 Correct 3 ms 93692 KB Output is correct
10 Correct 3 ms 93692 KB Output is correct
11 Correct 3 ms 93692 KB Output is correct
12 Correct 3 ms 93692 KB Output is correct
13 Runtime error 3 ms 93692 KB Execution killed with signal 8 (could be triggered by violating memory limits)
14 Halted 0 ms 0 KB -