Submission #308556

# Submission time Handle Problem Language Result Execution time Memory
308556 2020-10-01T14:32:49 Z shivensinha4 Lightning Conductor (POI11_pio) C++17
0 / 100
128 ms 64888 KB
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

const int MXV = 1e6, INF = 1e9;
int rt[MXV+1];
vi pos[MXV+1];

int main() {
	#ifdef shiven
	freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin >> n;
	vi h(n);
	int mx = 0;
	for_(i, 0, n) {
		cin >> h[i];
		mx = max(mx, h[i]);
		//if (!pos[h[i]].size()) pos[h[i]] = {i, i};
		//else pos[h[i]] = {min(pos[h[i]][0], i), max(pos[h[i]][1], i)};
	}
	
	int r = 0, sq = 0;
	for_(i, 0, mx+1) {
		rt[i] = r;
		if (i == sq) {
			r += 1;
			sq = r*r;
		}
	}
	
	//vi poss;
	//for (int i = mx; i >= max(mx-710, 0); i--) if (pos[i].size()) {
		 //poss.push_back(i);
	//}
	
	for_(i, 0, n) {
		int ans = h[i];
		for (int v = mx; v >= max(mx-710, 0); v--) if (pos[v].size()) ans = max({ans, v + rt[abs(pos[v][0] - i)], v + rt[abs(pos[v][1] - i)]});
		cout << ans-h[i] << endl;
	}
	

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 23808 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 23936 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 23808 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 56568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 58 ms 56824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 67 ms 57208 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 78 ms 57720 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 89 ms 60096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 99 ms 62200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 128 ms 64888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 117 ms 64760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -