Submission #1057152

#TimeUsernameProblemLanguageResultExecution timeMemory
1057152vjudge1Just Long Neckties (JOI20_ho_t1)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; using pii = pair<int, int>; using i64 = long long; const int MAXN = 2e5 + 5; int N; pii a[MAXN]; int b[MAXN]; int prefix[MAXN]; int suffix[MAXN]; int ans[MAXN]; signed main() { #define TASK "code" if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; for(int i = 1; i <= N + 1; i++) { cin >> a[i].first; a[i].second = i; } for(int i = 1; i <= N; i++) cin >> b[i]; sort(a + 1, a + N + 2); sort(b + 1, b + N + 1); // for(int i = 1; i <= N + 1; i++) cout << a[i].first << " "; for(int i = 1, j = 1; i <= N; i++) { int x = a[j].first - b[i]; prefix[j] = max(prefix[j - 1], x); j++; } for(int i = N, j = N + 1; i >= 1; i--) { int x = a[j].first - b[i]; // cout << a[j].first << " " << b[i] << "\n"; suffix[j] = max(suffix[j + 1], x); j--; } for(int i = 1; i <= N + 1; i++) ans[a[i].second] = max(prefix[i - 1], suffix[i + 1]); for(int i = 1; i <= N + 1; i++) cout << ans[i] << " ";

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:46:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |     for(int i = 1; i <= N + 1; i++) cout << ans[i] << " ";
      |     ^~~
ho_t1.cpp:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |     for(int i = 1; i <= N + 1; i++) cout << ans[i] << " ";
      | 
ho_t1.cpp:46:58: error: expected '}' at end of input
   46 |     for(int i = 1; i <= N + 1; i++) cout << ans[i] << " ";
      |                                                          ^
ho_t1.cpp:14:15: note: to match this '{'
   14 | signed main() {
      |               ^
ho_t1.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(TASK ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~