Submission #463532

# Submission time Handle Problem Language Result Execution time Memory
463532 2021-08-11T09:50:12 Z Mounir Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
125 ms 15484 KB
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define all(x) x.begin(), x.end()
#define pb push_back
#define pii pair<int, int>
#define deb first
#define fin second
#define int long long
using namespace std;
 
signed main(){ 
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);
 
      int nVals; cin >> nVals;
      vector<pii> avant(nVals + 1);
      for (int i  =0; i <= nVals; ++i){
            cin >> avant[i].first;
            avant[i].second = i;
      }

      vector<int> apres(nVals);
      for (int& e : apres)
            cin >> e;

      sort(all(avant));
      sort(all(apres));

      vector<int> res(nVals + 1);
      int maxi[2][nVals + 1];
      maxi[0][0] = max(avant[0].first - apres[0], 0ll);
      for (int i = 1; i < nVals; ++i)
            maxi[0][i] = max(maxi[0][i - 1], avant[i].first - apres[i]);
      maxi[1][nVals] = max(avant[nVals].first - apres[nVals - 1], 0ll);
      for (int i = nVals - 1; i > 0; --i)
            maxi[1][i] = max(maxi[1][i + 1], avant[i].first - apres[i - 1]);

      for (int i = 0; i <= nVals; ++i){
            res[avant[i].second] = 0;
            if (i != 0) chmax(res[avant[i].second], maxi[0][i - 1]);
            if (i != nVals) chmax(res[avant[i].second], maxi[1][i + 1]);
      }

      for (int e : res)
            cout << e << " ";
      cout << endl;
      return 0;
 
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 456 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 456 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 106 ms 14348 KB Output is correct
34 Correct 111 ms 15060 KB Output is correct
35 Correct 106 ms 14512 KB Output is correct
36 Correct 110 ms 15156 KB Output is correct
37 Correct 125 ms 15484 KB Output is correct
38 Correct 113 ms 15300 KB Output is correct
39 Correct 108 ms 14352 KB Output is correct
40 Correct 110 ms 14216 KB Output is correct
41 Correct 109 ms 14404 KB Output is correct
42 Correct 107 ms 14348 KB Output is correct
43 Correct 108 ms 14276 KB Output is correct
44 Correct 106 ms 13836 KB Output is correct
45 Correct 114 ms 13936 KB Output is correct
46 Correct 115 ms 13832 KB Output is correct
47 Correct 101 ms 14064 KB Output is correct
48 Correct 103 ms 14148 KB Output is correct
49 Correct 110 ms 14696 KB Output is correct
50 Correct 110 ms 14660 KB Output is correct
51 Correct 109 ms 14700 KB Output is correct
52 Correct 116 ms 14660 KB Output is correct
53 Correct 111 ms 14704 KB Output is correct