Submission #208980

#TimeUsernameProblemLanguageResultExecution timeMemory
208980davitmargJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
159 ms6264 KiB
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <unordered_map> #include <set> #include <queue> #include <iomanip> #include <bitset> #include <stack> #include <cassert> #include <iterator> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(), v.end() using namespace std; const int N = 200005; int n, b[N], sf[N], pr[N]; pair<int, int> a[N]; int main() { cin >> n; for (int i = 1; i <= n + 1; i++) { scanf("%d", &a[i].first); a[i].second = i; } for (int i = 1; i <= n; i++) scanf("%d", b + i); sort(a + 1, a + 1 + n + 1); sort(b + 1, b + 1 + n); for (int i = 1; i <= n; i++) pr[i] = max(pr[i - 1], a[i].first - b[i]); for (int i = n; i >= 1; i--) sf[i] = max(sf[i + 1], a[i + 1].first - b[i]); for (int i = 0; i <= n; i++) b[a[i + 1].second] = max(pr[i], sf[i + 1]); for (int i = 1; i <= n + 1; i++) printf("%d ", b[i]); cout << endl; return 0; } /* 10 5 3 5 2 3 6 9 7 3 90 12 3 6 9 8 5 2 4 6 3 5 */

Compilation message (stderr)

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