Submission #970724

#TimeUsernameProblemLanguageResultExecution timeMemory
970724hariaakas646Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
206 ms18568 KiB
#include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, j, k) for (int i = j; i < k; i++) #define frange(i, j) forr(i, 0, j) #define all(cont) cont.begin(), cont.end() #define mp make_pair #define pb push_back #define f first #define s second typedef long long int lli; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<lli> vll; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vi> vvi; typedef map<int, int> mpii; typedef set<int> seti; typedef multiset<int> mseti; typedef long double ld; void usaco() { freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin); // freopen("problem.out", "w", stdout); } int main() { // usaco(); int n; scd(n); vii vec(n+1); frange(i, n+1) { scd(vec[i].f); vec[i].s = i; } sort(all(vec)); vi sz(n); frange(i, n) scd(sz[i]); sort(all(sz)); int ma = 0; mseti st; frange(i, n) { st.insert(vec[i+1].f - sz[i]); } vi out(n+1); out[vec[0].s] = max(0, *prev(st.end())); forr(i, 1, n+1) { st.erase(st.find(vec[i].f - sz[i-1])); st.insert(vec[i-1].f-sz[i-1]); out[vec[i].s] = max(0, *prev(st.end())); } for(auto e : out) printf("%d ", e); }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:50:9: warning: unused variable 'ma' [-Wunused-variable]
   50 |     int ma = 0;
      |         ^~
ho_t1.cpp: In function 'void usaco()':
ho_t1.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
ho_t1.cpp:37:5: note: in expansion of macro 'scd'
   37 |     scd(n);
      |     ^~~
ho_t1.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
ho_t1.cpp:41:9: note: in expansion of macro 'scd'
   41 |         scd(vec[i].f);
      |         ^~~
ho_t1.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
ho_t1.cpp:47:18: note: in expansion of macro 'scd'
   47 |     frange(i, n) scd(sz[i]);
      |                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...