QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#453653 | #8781. Element-Wise Comparison | USP_USP_USP | TL | 0ms | 3764kb | C++14 | 1.3kb | 2024-06-24 06:33:48 | 2024-06-24 06:33:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
using ll = long long;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 2e5 + 5;
const int MOD = 1e9+7; //998244353;
const int INF = 0x3f3f3f3f;
const ll INF64 = ll(4e18) + 5;
void solve(){
int n;
cin >> n;
int m;
cin >> m;
vector<int> a(n);
//ainda nao uso que é uma permutacao, que caraio
for(int i = 0; i < n; i++){
cin >> a[i];
}
int ans = 0;
vector<int> dp(n+1);
//o problema dessa dp eh que eu movo e zero ao mesmo tempo
for(int i = n-2; i >= 0; i--){
for(int j = i+1; j < n; j++){
if(a[i] < a[j]){
dp[j] = dp[j+1]+1;
}else{
dp[j] = 0;
}
if(dp[j] >= m){
ans++;
}
}
}
cout << ans << '\n';
}
signed main(){
ios::sync_with_stdio(false); cin.tie(NULL);
int t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
/*
Makefile:
CXXFLAGS=-Wall -Wextra -Wshadow -g -pedantic -fsanitize=address,undefined -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUGPEDANTIC -std=gnu++17
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5 2 3 1 4 2 5
output:
2
result:
ok answer is '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
4 2 1 2 3 4
output:
3
result:
ok answer is '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
4 2 4 3 2 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3568kb
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...