QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#436362#8781. Element-Wise Comparisonucup-team3670#TL 0ms0kbC++201.8kb2024-06-09 00:15:322024-06-09 00:15:33

Judging History

你现在查看的是最新测评结果

  • [2024-06-09 00:15:33]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-06-09 00:15:32]
  • 提交

answer

#pragma GCC optimize("O3")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

//#define MULTITEST

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 50 * 1000 + 13;

int n, m;
int a[N];

bool read () {
	if (!(cin >> n >> m))
		return false;
	forn(i, n) cin >> a[i];
	n = 50000;
	m = 1;
	iota(a, a + n, 1);
	return true;
}

void solve() {
	int ans = 0;
	fore(d, 1, n){
		int cnt = 0;
		forn(i, n - d){
			if (a[i] < a[i + d])
				++cnt;
			else
				cnt = 0;
			ans += cnt >= m;
		}
	}
	cout << ans << '\n';
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;
	cin.tie(0);
	ios::sync_with_stdio(false);

#ifdef MULTITEST
	int tc;
	cin >> tc;
	while(tc--){
		read();
#else
	while(read()) {	
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

5 3
5 2 1 3 4

output:


result: