제출 #1087753

#제출 시각아이디문제언어결과실행 시간메모리
1087753tradzFinancial Report (JOI21_financial)C++14
0 / 100
32 ms14676 KiB
#include <bits/stdc++.h> #define For(i,a,b) for(int i = a; i <= b; i++) #define Ford(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define ii pair<int,int> #define fi first #define se second #define all(v) v.begin(),v.end() #define RRH(v) v.resize(unique(all(v)) - v.begin()) using namespace std; const int N = 1e6+7; const int M = 1e9+7; const ll oo = 3e18; int n, a[N], d, dp[N]; ii b[N]; int st[N]; stack<int> s; int R[N]; void up(int id, int l, int r, int u, int v) { if (l > u or r < u) return; if (l == r) { st[id] = v; return; } int mid = l + r >> 1; up(id * 2, l, mid, u, v); up(id * 2 + 1, mid + 1, r, u, v); st[id] = max(st[id * 2], st[id * 2 + 1]); } int get(int id, int l, int r, int u, int v) { if (l > v or r < u) return 0; if (u <= l and r <= v) return st[id]; int mid = l + r >> 1; return max(get(id * 2, l, mid, u, v), get(id * 2 + 1, mid + 1, r, u, v)); } int main() { ios::sync_with_stdio(0); cin.tie(0); #define TASK "" if (fopen (".inp", "r")) { freopen (".inp", "r", stdin); freopen (".out", "w", stdout); } if(fopen(TASK".inp", "r")) { freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); } cin >> n >> d; vector<int> v; For (i, 1, n) cin >> a[i], b[i] = {a[i], i}; Ford(i, n, 1) { while (s.size() && a[s.top()] <= a[i]) s.pop(); if (s.size() == 0) R[i] = n; else R[i] = s.top(); s.push(i); } For (i, 1, n) dp[i] = 0; sort (b + 1, b + n + 1, [](ii a, ii b) { if (a.fi == b.fi) return a.se > b.se; return a.fi > b.fi; }); memset(st, 0, sizeof st); queue<int> q; For (i, 1, n) { int pos = b[i].se; dp[pos] = dp[R[pos]] + 1; q.push(pos); } int ans = 0; For (i, 1, n) ans = max(ans, dp[i]); cout << ans << '\n'; return 0; }

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

Main.cpp: In function 'void up(int, int, int, int, int)':
Main.cpp:29:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   29 |     int mid = l + r >> 1;
      |               ~~^~~
Main.cpp: In function 'int get(int, int, int, int, int)':
Main.cpp:38:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |     int mid = l + r >> 1;
      |               ~~^~~
Main.cpp: In function 'int main()':
Main.cpp:47:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen (".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:48:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen (".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen(TASK".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen(TASK".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...