Submission #382183

# Submission time Handle Problem Language Result Execution time Memory
382183 2021-03-26T16:19:45 Z MODDI Lightning Conductor (POI11_pio) C++14
0 / 100
225 ms 13712 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int n;
vl arr;
bool check(int height, int pos){
	for(int i = 0; i < n; i++){
		if(i == pos)
			continue;
		else{
			if(arr[i]<= arr[pos] + height - sqrt(abs(i - pos)))
				continue;
			else
				return false;
		}
	}
}	
int main(){
	
	cin>>n;
	for(int i = 0; i < n; i++){
		int a;
		cin>>a;
		arr.pb(a);
	}
	for(int i = 0; i < n; i++){
		int l = 1, r = 1000000, mid;
		while(l <= r){
			int mid = (l + r) / 2;
			bool good = check(mid, i);
			if(good)
				r = mid - 1;
			else
				l = mid + 1;
		}
		cout<<l<<endl;
	}
	return 0;
}

Compilation message

pio.cpp: In function 'int main()':
pio.cpp:33:27: warning: unused variable 'mid' [-Wunused-variable]
   33 |   int l = 1, r = 1000000, mid;
      |                           ^~~
pio.cpp: In function 'bool check(int, int)':
pio.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 1512 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 2036 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 2460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 45 ms 3168 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 105 ms 6620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 161 ms 9684 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 222 ms 13396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 225 ms 13712 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -