제출 #314276

#제출 시각아이디문제언어결과실행 시간메모리
314276BeanZ거래 (IZhO13_trading)C++14
100 / 100
201 ms13924 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 3e5 + 5; struct viet{ ll l, r, x; bool operator <(const viet &o) const{ return l < o.l; } }a[N]; struct lpl{ ll l, r, x; bool operator <(const lpl &o) const{ return (l - x) > (o.l - o.x); } }; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n, m; cin >> n >> m; for (int i = 1; i <= m; i++){ cin >> a[i].l >> a[i].r >> a[i].x; } sort(a + 1, a + m + 1); ll now = 1; priority_queue<lpl> pq; for (int i = 1; i <= n; i++){ while (now <= m && a[now].l == i){ lpl x = {a[now].l, a[now].r, a[now].x}; pq.push(x); now++; } while (pq.size()){ if (pq.top().r < i) pq.pop(); else break; } if (pq.size() == 0) cout << 0 << " "; else { cout << i - pq.top().l + pq.top().x << " "; } } } /* */

컴파일 시 표준 에러 (stderr) 메시지

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