Submission #1043941

# Submission time Handle Problem Language Result Execution time Memory
1043941 2024-08-05T04:54:10 Z 김은성(#11005) Measures (CEOI22_measures) C++17
24 / 100
1500 ms 7320 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(vector<ll> a, ll D){
	vector<ll> d;
	sort(a.begin(), a.end());
	int i;
	for(i=0; i+1<a.size(); i++){
		d.push_back(D - a[i+1] + a[i]);
	}
	ll ans = 0, ret = 0;
	for(i=0; i<d.size(); i++){
		ans = max(ans + d[i], 0ll);
		ret = max(ret, ans);
	}
	return ret;
}
int main(){
	int n, m, D, i;
	ll val;
	scanf("%d %d", &n, &m);
	scanf("%d", &D);
	vector<ll> a;
	for(i=0; i<n; i++){
		scanf("%lld", &val);
		a.push_back(val);
	}
	for(i=0; i<m; i++){
		scanf("%lld", &val);
		a.push_back(val);
		ll ret = solve(a, D);
		if(ret % 2 == 0)
			printf("%lld ", ret/2);
		else
			printf("%lld.5 ", ret/2);
	}
	return 0;
}

Compilation message

Main.cpp: In function 'll solve(std::vector<long long int>, ll)':
Main.cpp:8:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for(i=0; i+1<a.size(); i++){
      |           ~~~^~~~~~~~~
Main.cpp:12:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(i=0; i<d.size(); i++){
      |           ~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d", &D);
      |  ~~~~~^~~~~~~~~~
Main.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   scanf("%lld", &val);
      |   ~~~~~^~~~~~~~~~~~~~
Main.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%lld", &val);
      |   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 142 ms 7320 KB Output is correct
10 Correct 120 ms 7180 KB Output is correct
11 Correct 70 ms 7180 KB Output is correct
12 Correct 168 ms 7180 KB Output is correct
13 Correct 64 ms 7176 KB Output is correct
14 Correct 103 ms 7184 KB Output is correct
15 Correct 136 ms 7192 KB Output is correct
16 Correct 58 ms 7188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1574 ms 1036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1574 ms 1036 KB Time limit exceeded
2 Halted 0 ms 0 KB -