#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const double PI = 4 * atan(1);
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define vi vector<int>
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define vpi vector<pair<int, int>>
#define vpd vector<pair<double, double>>
#define pd pair<double, double>
#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
void fast_io(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
void io(string taskname){
string fin = taskname + ".in";
string fout = taskname + ".out";
const char* FIN = fin.c_str();
const char* FOUT = fout.c_str();
freopen(FIN, "r", stdin);
// freopen(FOUT, "w", stdout);
fast_io();
}
const int MAX = 5e5 + 5;
set<int> elements;
unordered_map<int, int> um;
int cnt [MAX];
vi cur;
int n, q;
vector<int> a, v, x;
inline int upd(int loc, int val){
if(val == cur[loc]){
int mx = 0;
f0r(i, n){
mx = max(mx, cnt[i]);
}
return mx;
}
cnt[loc] = 0;
f0r(i, loc){
if(cur[i]>val){
cnt[loc]++;
}
}
f1r(i, loc+1, n){
if(val>cur[i]){
if(cur[loc] >cur[i]) continue;
cnt[i]++;
}
else{
if(cur[loc]>cur[i]){
cnt[i]--;
}
}
}
cur[loc] = val;
int mx = 0;
f0r(i, n){
mx = max(mx, cnt[i]);
}
return mx;
}
vi countScans(vi a1, vi x1, vi v1){
a = a1;
x = x1;
v = v1;
n = sz(a);
q = sz(x);
f0r(i, n) elements.insert(a[i]);
f0r(i, q) elements.insert(v[i]);
int num = 0;
for(auto e: elements){
um[e] = num;
num++;
}
f0r(i, n) a[i] = um[a[i]];
f0r(i, q) v[i] = um[v[i]];
f0r(i, n) cur.eb(0);
f0r(i, n){
upd(i, a[i]);
}
vi ret;
f0r(i, q){
ret.eb(upd(x[i], v[i]));
}
return ret;
}
/*
int main(){
int n, q;
cin >> n >> q;
vi v1, v2, v3;
f0r(i, n){
int x;
cin >> x;
v1.eb(x);
}
f0r(i, q){
int x;
cin >> x;
v2.eb(x);
}
f0r(i, q){
int x;
cin >> x;
v3.eb(x);
}
cout << countScans(v1, v2, v3) << endl;
return 0;
}*/
Compilation message
bubblesort2.cpp:1:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/stack:200000000")
bubblesort2.cpp: In function 'void io(std::__cxx11::string)':
bubblesort2.cpp:53:17: warning: unused variable 'FOUT' [-Wunused-variable]
const char* FOUT = fout.c_str();
^~~~
bubblesort2.cpp:54:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen(FIN, "r", stdin);
~~~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
8 ms |
504 KB |
Output is correct |
3 |
Correct |
34 ms |
884 KB |
Output is correct |
4 |
Correct |
34 ms |
760 KB |
Output is correct |
5 |
Correct |
27 ms |
760 KB |
Output is correct |
6 |
Correct |
17 ms |
1016 KB |
Output is correct |
7 |
Correct |
20 ms |
888 KB |
Output is correct |
8 |
Correct |
23 ms |
760 KB |
Output is correct |
9 |
Correct |
27 ms |
888 KB |
Output is correct |
10 |
Correct |
22 ms |
760 KB |
Output is correct |
11 |
Correct |
22 ms |
860 KB |
Output is correct |
12 |
Correct |
22 ms |
760 KB |
Output is correct |
13 |
Correct |
22 ms |
808 KB |
Output is correct |
14 |
Correct |
21 ms |
888 KB |
Output is correct |
15 |
Correct |
21 ms |
760 KB |
Output is correct |
16 |
Correct |
20 ms |
760 KB |
Output is correct |
17 |
Correct |
20 ms |
700 KB |
Output is correct |
18 |
Correct |
20 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
8 ms |
504 KB |
Output is correct |
3 |
Correct |
34 ms |
884 KB |
Output is correct |
4 |
Correct |
34 ms |
760 KB |
Output is correct |
5 |
Correct |
27 ms |
760 KB |
Output is correct |
6 |
Correct |
17 ms |
1016 KB |
Output is correct |
7 |
Correct |
20 ms |
888 KB |
Output is correct |
8 |
Correct |
23 ms |
760 KB |
Output is correct |
9 |
Correct |
27 ms |
888 KB |
Output is correct |
10 |
Correct |
22 ms |
760 KB |
Output is correct |
11 |
Correct |
22 ms |
860 KB |
Output is correct |
12 |
Correct |
22 ms |
760 KB |
Output is correct |
13 |
Correct |
22 ms |
808 KB |
Output is correct |
14 |
Correct |
21 ms |
888 KB |
Output is correct |
15 |
Correct |
21 ms |
760 KB |
Output is correct |
16 |
Correct |
20 ms |
760 KB |
Output is correct |
17 |
Correct |
20 ms |
700 KB |
Output is correct |
18 |
Correct |
20 ms |
764 KB |
Output is correct |
19 |
Correct |
387 ms |
2356 KB |
Output is correct |
20 |
Correct |
492 ms |
2552 KB |
Output is correct |
21 |
Correct |
290 ms |
2576 KB |
Output is correct |
22 |
Correct |
383 ms |
2448 KB |
Output is correct |
23 |
Correct |
295 ms |
2224 KB |
Output is correct |
24 |
Correct |
296 ms |
2344 KB |
Output is correct |
25 |
Correct |
279 ms |
2044 KB |
Output is correct |
26 |
Correct |
284 ms |
2296 KB |
Output is correct |
27 |
Correct |
269 ms |
2040 KB |
Output is correct |
28 |
Correct |
265 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2081 ms |
1192 KB |
Output is correct |
2 |
Correct |
8572 ms |
2408 KB |
Output is correct |
3 |
Execution timed out |
9028 ms |
3188 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
8 ms |
504 KB |
Output is correct |
3 |
Correct |
34 ms |
884 KB |
Output is correct |
4 |
Correct |
34 ms |
760 KB |
Output is correct |
5 |
Correct |
27 ms |
760 KB |
Output is correct |
6 |
Correct |
17 ms |
1016 KB |
Output is correct |
7 |
Correct |
20 ms |
888 KB |
Output is correct |
8 |
Correct |
23 ms |
760 KB |
Output is correct |
9 |
Correct |
27 ms |
888 KB |
Output is correct |
10 |
Correct |
22 ms |
760 KB |
Output is correct |
11 |
Correct |
22 ms |
860 KB |
Output is correct |
12 |
Correct |
22 ms |
760 KB |
Output is correct |
13 |
Correct |
22 ms |
808 KB |
Output is correct |
14 |
Correct |
21 ms |
888 KB |
Output is correct |
15 |
Correct |
21 ms |
760 KB |
Output is correct |
16 |
Correct |
20 ms |
760 KB |
Output is correct |
17 |
Correct |
20 ms |
700 KB |
Output is correct |
18 |
Correct |
20 ms |
764 KB |
Output is correct |
19 |
Correct |
387 ms |
2356 KB |
Output is correct |
20 |
Correct |
492 ms |
2552 KB |
Output is correct |
21 |
Correct |
290 ms |
2576 KB |
Output is correct |
22 |
Correct |
383 ms |
2448 KB |
Output is correct |
23 |
Correct |
295 ms |
2224 KB |
Output is correct |
24 |
Correct |
296 ms |
2344 KB |
Output is correct |
25 |
Correct |
279 ms |
2044 KB |
Output is correct |
26 |
Correct |
284 ms |
2296 KB |
Output is correct |
27 |
Correct |
269 ms |
2040 KB |
Output is correct |
28 |
Correct |
265 ms |
1912 KB |
Output is correct |
29 |
Correct |
2081 ms |
1192 KB |
Output is correct |
30 |
Correct |
8572 ms |
2408 KB |
Output is correct |
31 |
Execution timed out |
9028 ms |
3188 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |