Submission #443236

# Submission time Handle Problem Language Result Execution time Memory
443236 2021-07-10T08:15:53 Z gs12117 Meteors (POI11_met) C++14
74 / 100
2166 ms 40776 KB
#include<cstdio>
#include<vector>
int n, m, q;
int o[300100];
std::vector<int> owned_stn[300100];
long long int p[300100];
int l[300100];
int r[300100];
long long int a[300100];
int ans[300100];
std::vector<int> check_for_q[300100];
const long long int itsz = 1 << 19;
long long int it[2 * itsz];
void itpush(int s, int e, long long int v) {
	s += itsz;
	e += itsz;
	while (s <= e) {
		if (s % 2 == 1) {
			it[s] += v;
			s++;
		}
		if (e % 2 == 0) {
			it[e] += v;
			e--;
		}
		s /= 2;
		e /= 2;
	}
}
long long int itcalc(int x) {
	x += itsz;
	long long int res = 0;
	while (x > 0) {
		res += it[x];
		x /= 2;
	}
	return res;
}
long long int calcx(int x) {
	long long int sum = 0;
	for (int i = 0; i < owned_stn[x].size(); i++) {
		sum += itcalc(owned_stn[x][i]);
	}
	return sum;
}
void para_chk(int x, int parav) {
	if (p[x] <= calcx(x))ans[x] -= parav;
}
void para(int parav) {
	for (int i = 0; i <= q + 3; i++) {
		check_for_q[i].clear();
	}
	for (int i = 1; i <= n; i++) {
		ans[i] += parav;
		if (ans[i] > q)ans[i] -= parav;
		else check_for_q[ans[i]].push_back(i);
	}
	for (int i = 0; i < 2 * itsz; i++) {
		it[i] = 0;
	}
	for (int i = 1; i <= q; i++) {
		if (l[i] <= r[i]) {
			itpush(l[i], r[i], a[i]);
		}
		else {
			itpush(l[i], m, a[i]);
			itpush(1, r[i], a[i]);
		}
		for (int j = 0; j < check_for_q[i].size(); j++) {
			int x = check_for_q[i][j];
			para_chk(x, parav);
		}
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf("%d", &o[i]);
		owned_stn[o[i]].push_back(i);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &p[i]);
	}
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		scanf("%d%d%lld", &l[i], &r[i], &a[i]);
	}
	for (int i = 18; i >= 0; i--) {
		para(1 << i);
	}
	for (int i = 1; i <= n; i++) {
		if (ans[i] >= q) {
			printf("NIE\n");
		}
		else {
			printf("%d\n", ans[i] + 1);
		}
	}
	return 0;
}

Compilation message

met.cpp: In function 'long long int calcx(int)':
met.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for (int i = 0; i < owned_stn[x].size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~~~~~~
met.cpp: In function 'void para(int)':
met.cpp:69:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |   for (int j = 0; j < check_for_q[i].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~~~~~~~~
met.cpp: In function 'int main()':
met.cpp:76:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
met.cpp:78:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |   scanf("%d", &o[i]);
      |   ~~~~~^~~~~~~~~~~~~
met.cpp:82:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |   scanf("%lld", &p[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
met.cpp:84:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
met.cpp:86:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |   scanf("%d%d%lld", &l[i], &r[i], &a[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 24 ms 22676 KB Output is correct
2 Correct 27 ms 22680 KB Output is correct
3 Correct 25 ms 22604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 22604 KB Output is correct
2 Correct 28 ms 22672 KB Output is correct
3 Correct 26 ms 22704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 24988 KB Output is correct
2 Correct 276 ms 26244 KB Output is correct
3 Correct 260 ms 26692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 271 ms 26080 KB Output is correct
2 Correct 260 ms 26224 KB Output is correct
3 Correct 315 ms 27144 KB Output is correct
4 Correct 64 ms 24764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 142 ms 25520 KB Output is correct
2 Correct 161 ms 27044 KB Output is correct
3 Correct 145 ms 24112 KB Output is correct
4 Correct 263 ms 27156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 271 ms 24696 KB Output is correct
2 Correct 271 ms 26164 KB Output is correct
3 Correct 222 ms 24900 KB Output is correct
4 Correct 302 ms 27992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2098 ms 40776 KB Output is correct
2 Incorrect 722 ms 30492 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2166 ms 39884 KB Output is correct
2 Incorrect 692 ms 30524 KB Output isn't correct
3 Halted 0 ms 0 KB -