Submission #1111914

#TimeUsernameProblemLanguageResultExecution timeMemory
1111914vjudge1Trading (IZhO13_trading)C++17
100 / 100
283 ms39112 KiB
#include <bits/stdc++.h> #define task "TEST" #define task2 "A" #define pl pair<ll, ll> #define VI vector<ll> #define pf push_front #define pb push_back #define pob pop_back #define pof pop_front #define mp make_pair #define fi first #define se second #define FOR(i, a, b, c) for (int i=a; i<=b; i+=c) #define FORE(i, a, b, c) for (int i=a; i>=b; i+=c) using namespace std; using ll = long long; using lll = __int128; using ull = unsigned long long; using ulll = unsigned __int128; const int Mod = 1e9+7; const int maxn = 3e5+1; const ll Inf = 3e9; pl A[maxn+1]; ll n, m; vector<ll> add[maxn+1], del[maxn+1]; multiset<ll> S; ll a, b, c, res[maxn+1]; void Read() { cin >> n >> m; FOR(i, 1, m, 1) { cin >> a >> b >> c; add[a].pb(c-a); del[b+1].pb(c-a); } } void Solve() { FOR(i, 1, n, 1) { for(auto v : add[i]) S.insert(v); for(auto v : del[i]) S.erase(S.find(v)); res[i] = (S.size() ? *S.rbegin() + i : 0); } FOR(i, 1, n, 1) cout << res[i] << " "; } int main() { 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); int t; //Sieve(); for (t=1; t--;) { Read(); Solve(); } }

Compilation message (stderr)

trading.cpp: In function 'int main()':
trading.cpp:49:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
trading.cpp:50:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...