# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1141195 | SmuggingSpun | Financial Report (JOI21_financial) | C++20 | 1508 ms | 116408 KiB |
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
template<class T>bool maximize(T& a, T b){
if(a < b){
a = b;
return true;
}
return false;
}
int n, d;
namespace sub1{
void solve(){
vector<int>a(n);
for(int& x : a){
cin >> x;
}
int ans = 0;
for(int mask = (1 << n) - 1; mask > 0; mask--){
vector<int>index;
for(int i = 0; i < n; i++){
if(1 << i & mask){
if(!index.empty() && i - index.back() > d){
index.clear();
break;
}
index.emplace_back(i);
}
}
if(!index.empty() && index.back() == n - 1){
int cnt = 0, cur_max = -1;
for(int& x : index){
if(maximize(cur_max, a[x])){
cnt++;
}
}
maximize(ans, cnt);
}
}
cout << ans;
}
}
namespace sub5{
const int LIM = 1e9 + 5;
void solve(){
map<int, int>bit;
auto update = [&] (int p, int x){
for(p++; p < LIM; p += p & -p){
maximize(bit[p], x);
}
};
auto get = [&] (int p){
int ans = 0;
for(; p > 0; p -= p & -p){
auto it = bit.find(p);
if(it != bit.end()){
maximize(ans, it->second);
}
}
return ans;
};
for(int i = 0; true; i++){
int x;
cin >> x;
int LIS = get(x) + 1;
update(x, LIS);
if(i + 1 == n){
cout << get(LIM - 1);
break;
}
}
}
}
namespace sub2346{
void solve(){
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> d;
if(n <= 20){
sub1::solve();
}
else if(d == n){
sub5::solve();
}
else{
sub2346::solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |