Submission #1023644

# Submission time Handle Problem Language Result Execution time Memory
1023644 2024-07-15T04:08:51 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
const int mod = 998244353;
void solve() {
	int n;
	cin >> n;
	vector <int> v(n + 1);
	for (int i = 0; i <= n; i++) {
		cin >> v[i];
	}
	vector <int> a(n);
	for (int i = 0; i < n; i++)  {
		cin >> a[i];
	}
	vector <int> v1 = v, a1 = a, ans;
	sort(v1.begin(), v1.end());
	sort(a1.begin(), a1.end());
	for (int i = 0;  i < n + 1; i++) {
		int k = 0, mx = 0;
		for (int j = 0; j < n; j++) {
			if (v1[j] == v[i]) {
				continue;
			}
			mx = max(mx, abs(v1[j] - a1[k]));
			k++;
		}
		ans.pb(mx);
	}
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << " ";
	}
	
}
signed main() {
    int t = 1;
    //cin >> t;
	while (t--) {
		solve();
	}
}

Compilation message

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:35:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (int i = 0; i < ans.size(); i++) {
      |                  ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -