이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);
#define ll long long
#define for_t ll T;cin>>T;while(T--)
#define endl "\n"
#define F(a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define pb push_back
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,std::less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/
void sol()
{
ll n,m;
cin >> n >> m;
ll a[n + 1];
for(int i = 1;i <= n;i++)
{
cin >> a[i];
a[i] = (m * i) - a[i];
}
vector<ll> v;
vector<ll>::iterator it;
for(int i = 1;i <= n;i++)
{
if(a[i] < 0)
{
continue;
}
if(v.empty() || a[i] >= v.back())
{
v.pb(a[i]);
}
else
{
it = upper_bound(all(v),a[i]);
*it = a[i];
}
}
cout << n - v.size() << endl;
}
int main()
{
FIO
//freopen("time.in","r",stdin);
//freopen("time.out","w",stdout);
//iota(all(link),0);
sol();
}
| # | 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... |