답안 #1023693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023693 2024-07-15T04:51:44 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 600 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<pair <int, int> > v(n + 1);
    vector<int> a1(n);
    for (int i = 0; i <= n; i++) {
        cin >> v[i].f;
        v[i].s = i;
    }
    for (int i = 0; i < n; i++) {
        cin >> a1[i];
    }
    vector<int> ans(n + 1);
    sort(a1.begin(), a1.end());
	sort(v.begin(), v.end());
    for (int i = 0; i <= n; i++) {
        int  mx = 0;
        int k = 0;
        for (int j = 0; j < n; j++) {
        	if (v[j].s == i) {
        		continue;
			}
            mx = max(mx, abs(v[j].f - a1[k]));
            k++;
        }
        ans[v[i].s] = mx;
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << " ";
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}

Compilation message

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:37:23: 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]
   37 |     for (int i = 0; i < ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -