QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#437056 | #8781. Element-Wise Comparison | ucup-team2000# | TL | 1ms | 4176kb | C++20 | 1.4kb | 2024-06-09 04:45:14 | 2024-06-09 04:45:15 |
Judging History
answer
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
#define sz(x) (int)(x.size())
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
const int mxN = 5e4 + 5;
mt19937 rng((ll)std::chrono::steady_clock::now().time_since_epoch().count());
int dp[2][mxN];
void solve(){
int n, m;
cin >> n >> m;
vi p(n + 1);
repn(i, 1, n + 1) cin >> p[i];
int ans = 0;
memset(dp, -1, sizeof(dp));
repn(i, 1, n + 1){
int cr = i & 1, pr = 1 - (i & 1);
repn(j, i + 1, n + 1){
dp[cr][j] = 0;
if(p[i] < p[j]){
dp[cr][j] = 1;
dp[cr][j] = max(dp[cr][j], dp[pr][j - 1] + 1);
}
if(dp[cr][j] >= m) ans++;
}
memset(dp[pr], -1, sizeof(dp[pr]));
}
cout << ans << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
//freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
int t = 1;
//cin >> t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4008kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
5 2 3 1 4 2 5
output:
2
result:
ok answer is '2'
Test #3:
score: 0
Accepted
time: 1ms
memory: 4176kb
input:
4 2 1 2 3 4
output:
3
result:
ok answer is '3'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3984kb
input:
4 2 4 3 2 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 1ms
memory: 4064kb
input:
1 1 1
output:
0
result:
ok answer is '0'
Test #6:
score: -100
Time Limit Exceeded
input:
50000 2 44045 29783 5389 7756 44022 45140 21967 5478 10868 49226 21775 31669 49836 13511 46116 14229 27206 31168 37389 3158 10658 41154 14635 18526 40540 6451 23197 46719 30593 13517 8604 46666 39189 43746 12778 3684 3194 36979 43020 14652 19549 31178 17144 27177 44336 2849 40220 11751 41993 32209 4...