제출 #1119143

#제출 시각아이디문제언어결과실행 시간메모리
1119143CadocFinancial Report (JOI21_financial)C++14
0 / 100
4051 ms5136 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define el cout << '\n' #define INF 0x3f3f3f3f #define LINF 0x3f3f3f3f3f3f3f3f #define N 300005 int n, d; int a[N]; int par[N], sz[N]; int dp[N]; int get(int u){ return par[u] = (u == par[u]? u:get(par[u])); } int join(int u, int v){ u = get(u), v = get(v); if(u == v) return 0; if(sz[u] < sz[v]) swap(u, v); sz[u] += sz[v]; par[v] = u; return 1; } void Solve(){ cin >> n >> d; for(int i=1; i<=n; ++i) cin >> a[i]; for(int i=1; i<=n; ++i){ par[i] = i; sz[i] = 1; } for(int i=1; i<=n; ++i){ dp[i] = 1; for(int j=max(1, i-d); j<i; ++j) if(a[j] >= a[i]) join(i, j); for(int j=1; j<i; ++j) if(j >= i-d || get(i) == get(j)){ if(a[j] < a[i]){ dp[i] = max(dp[i], dp[j] + 1); } } } int Ans = 1; for(int i=1; i<=n; ++i) if(get(n) == get(i) || i >= n-d) Ans = max(Ans, dp[i]); cout << Ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define NAME "TASK" if(fopen(NAME".inp", "r")){ freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout); } Solve(); return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen(NAME".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen(NAME".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...