제출 #1119151

#제출 시각아이디문제언어결과실행 시간메모리
1119151CadocFinancial Report (JOI21_financial)C++14
0 / 100
4035 ms4432 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 mark[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]) mark[get(j)] = 1; for(int j=1; j<i; ++j) if(j >= i-d || mark[get(j)]){ if(a[j] < a[i]){ dp[i] = max(dp[i], dp[j] + 1); } } for(int j=max(1, i-d); j<i; ++j){ if(a[j] < a[i]) mark[get(j)] = 0; else join(i, j); } } 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:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen(NAME".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         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...