제출 #892177

#제출 시각아이디문제언어결과실행 시간메모리
892177Peter2017Financial Report (JOI21_financial)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define pill pair<int,ll> #define mem(a, b) memset(a, b, sizeof(a)) #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define name "test" using namespace std; const int N = 3e5 + 5; const int mod = 1e9 + 7; const ll oo = 1e18 + 69; template <typename T1, typename T2> bool maxi(T1 &a, T2 b){if (a < b){a = b; return 1;} return 0;} template <typename T1, typename T2> bool mini(T1 &a, T2 b){if (a > b){a = b; return 1;} return 0;} int n; int k; int D; int a[N]; int f[(int)7e3 + 2][(int)7e3 + 2]; deque <int> dq[(int)7e3 + 2]; vector <int> value; void load(){ cin.tie(0)->sync_with_stdio(0); if (fopen(name".inp", "r")){ freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } } void input(){ cin >> n >> D; for (int i = 1; i <= n; i++){ cin >> a[i]; } } void compress(){ for (int i = 1; i <= n; i++) value.push_back(a[i]); sort(value.begin(), value.end()); value.erase(unique(value.begin(), value.end()), value.end()); for (int i = 1; i <= n; i++) a[i] = lower_bound(value.begin(), value.end(), a[i]) - value.begin() + 1; k = (int)value.size(); } namespace subtask3{ void solve(){ mem(f, -0x3f); for (int i = 1; i <= n; i++){ f[i][a[i]] = 1; for (int j = 1; j <= k; j++){ if (dq[j].size() && dq[j].front() < i - D) dq[j].pop_front(); if (dq[j].size()) maxi(f[i][max(a[i], j)], f[dq[j].front()][j] + (j < a[i])); } for (int j = 1; j <= k; j++){ while (dq[j].size() && f[dq[j].back()][j] <= f[i][j]) dq[j].pop_back(); dq[j].push_back(i); } } int ans = 0; for (int i = 1; i <= k; i++) maxi(ans, f[n][i]); cout << ans; } } namespace subtask4{ stack <int> st; void solve(){ st.push(n); int ans = 1; for (int i = n - 1; i >= 1; i--){ while (st.size() && a[st.top()] <= a[i]) st.pop(); st.push(i); maxi(ans, st.size()); } cout << ans; } } namespace subtask5{ int b[N]; void solve(){ mem(b, 0x3f); f[0] = -mod; int ans = 0; for (int i = 1; i <= n; i++){ int id = lower_bound(b + 1, b + n + 1, a[i]) - b; // if (i == n) cout << id; b[id] = a[i]; maxi(ans, id); } cout << ans; } } int main(){ load(); input(); compress(); if (n <= (int)7e3){ subtask3::solve(); return 0; } if (D == 1){ subtask4::solve(); return 0; } subtask5::solve(); }

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

Main.cpp: In function 'void subtask5::solve()':
Main.cpp:95:14: error: incompatible types in assignment of 'int' to 'int [7002]'
   95 |         f[0] = -mod;
      |         ~~~~~^~~~~~
Main.cpp: In instantiation of 'bool maxi(T1&, T2) [with T1 = int; T2 = long unsigned int]':
Main.cpp:85:32:   required from here
Main.cpp:19:66: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
   19 | template <typename T1, typename T2> bool maxi(T1 &a, T2 b){if (a < b){a = b; return 1;} return 0;}
      |                                                                ~~^~~
Main.cpp: In function 'void load()':
Main.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~