Submission #446757

#TimeUsernameProblemLanguageResultExecution timeMemory
446757maomao90Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
123 ms13184 KiB
#include <bits/stdc++.h> using namespace std; template <class T> inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;} template <class T> inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;} #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; #define MT make_tuple typedef tuple<int, int, int> iii; #define ALL(_a) _a.begin(), _a.end() #define pb push_back typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; #ifdef DEBUG #define debug(args...) _debug(args) void _debug(const char* format, ...) { va_list args; va_start(args, format); vprintf(format, args); va_end(args); } #else #define debug(args...) #endif #define INF 1000000005 #define LINF 1000000000000000005 #define MOD 1000000007 #define MAXN 200005 int n; ii a[MAXN]; int b[MAXN]; ll pre[MAXN], pst[MAXN], ans[MAXN]; int main() { scanf("%d", &n); REP (i, 1, n + 2) { scanf("%d", &a[i].FI); a[i].SE = i; } REP (i, 1, n + 1) { scanf("%d", &b[i]); } sort(a + 1, a + n + 2); sort(b + 1, b + n + 1); REP (i, 1, n + 1) { pre[i] = max(a[i].FI - b[i], 0); debug("%d: %d\n", i, pre[i]); mxto(pre[i], pre[i - 1]); } RREP (i, n + 1, 2) { pst[i] = max(a[i].FI - b[i - 1], 0); debug("%d: %d\n", i, pst[i]); mxto(pst[i], pst[i + 1]); } REP (i, 1, n + 2) { debug("%d: %d %d\n", a[i].SE, pre[i - 1], pst[i + 1]); ans[a[i].SE] = max(pre[i - 1], pst[i + 1]); } REP (i, 1, n + 2) { printf("%lld ", ans[i]); } printf("\n"); return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
ho_t1.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   scanf("%d", &a[i].FI);
      |   ~~~~~^~~~~~~~~~~~~~~~
ho_t1.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |   scanf("%d", &b[i]);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...