Submission #1047955

# Submission time Handle Problem Language Result Execution time Memory
1047955 2024-08-07T18:42:39 Z DeathIsAwe Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main() {
    int n; cin >> n;
    vector<int> newties(n+1), oldties(n), unsortednew;
    unordered_map<int,ll> ansmap, strange;
    for (int i=0;i<n+1;i++) {
        cin >> newties[i];
    }
    for (int i=0;i<n;i++) {
        cin >> oldties[i];
    }
    unsortednew = newties;


    sort(newties.begin(), newties.end());
    sort(oldties.begin(), oldties.end());
    priority_queue<ll> lol;
    ll ans = 0, dummy;
    for (int i=0;i<n;i++) {
        dummy = max(newties[i+1] - oldties[i], 0);
        if (strange.find(dummy) != strange.end()) {
            strange[dummy] += 1;
        } else {
            strange[dummy] = 1;
        }
        lol.push(dummy);
    }
    cout << 1/0;
    ansmap[newties[0]] = lol.top();
    for (int i=0;i<n;i++) {
        dummy = max(newties[i+1] - oldties[i], 0);
        strange[dummy] -= 1;
        dummy = max(newties[i] - oldties[i], 0);
        if (strange.find(dummy) != strange.end()) {
            strange[dummy] += 1;
        } else {
            strange[dummy] = 1;
        }
        while (strange[lol.top()] == 0) {
            lol.pop();
        }
        ansmap[newties[i+1]] = lol.top();
    }
    for (int i=0;i<n+1;i++) {
        cout << ansmap[unsortednew[i]] << ' ';
    }
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:32:14: warning: division by zero [-Wdiv-by-zero]
   32 |     cout << 1/0;
      |             ~^~
ho_t1.cpp:22:8: warning: unused variable 'ans' [-Wunused-variable]
   22 |     ll ans = 0, dummy;
      |        ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -