Submission #691781

#TimeUsernameProblemLanguageResultExecution timeMemory
691781tolbiMoney (IZhO17_money)C++17
100 / 100
1439 ms61888 KiB
#pragma optimize("Bismillahirrahmanirrahim") //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█■█ //█─█─█▄─█▄─█─█─█─█ //Allahuekber //ahmet23 orz... //Sani buyuk Osman Pasa Plevneden cikmam diyor. //FatihSultanMehmedHan //YavuzSultanSelimHan //AbdulhamidHan #define author tolbi #include <bits/stdc++.h> #ifdef LOCAL #include "23.h" #endif #define endl '\n' #define vint(x) vector<int> x #define deci(x) int x;cin>>x; #define decstr(x) string x;cin>>x; #define cinarr(x) for (auto &it : x) cin>>it; #define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl; #define sortarr(x) sort(x.begin(),x.end()) #define sortrarr(x) sort(x.rbegin(),x.rend()) #define det(x) cout<<"NO\0YES"+x*3<<endl; #define INF LONG_LONG_MAX #define rev(x) reverse(x.begin(),x.end()); #define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define tol(bi) (1LL<<((int)(bi))) const int MOD = 1e9+7; using namespace std; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); struct BIT{ vector<int> fenwik; BIT(int n){ fenwik.resize(2*n); } void update(int node){ for (; node<fenwik.size(); node=node|(node+1)) fenwik[node]++; } int get(int node){ int rval = 0; for (; node>=0; node=(node&(node+1))-1) rval+=fenwik[node]; return rval; } int query(int l, int r){ int hh = 0; if (l) hh = get(l-1); if (l>r) return 0ll; return get(r)-hh; } }; void compress(vector<int> &arr){ vector<int> barr = arr; map<int,int> mp; sortarr(barr); int ind = 1; for (int i = 0; i < arr.size(); i++){ if (mp[barr[i]]) continue; mp[barr[i]]=ind++; } for (int i = 0; i < arr.size(); ++i) { arr[i]=mp[arr[i]]; } } int32_t main(){ ios; int t=1; int tno = 0; if (!t) cin>>t; while (t-(tno++)){ deci(n); vint(arr(n)); cinarr(arr); compress(arr); BIT fenwik(n); int ans = n; fenwik.update(arr[0]); vector<int> barr=arr; int ind = 1; for (int i = 1; i < n; i++){ if (arr[i]>=barr[i-1]){ if (fenwik.query(arr[i-1]+1,arr[i]-1)==0){ ans--; arr[i]=arr[i-1]; } else { while (ind<=i){ fenwik.update(barr[ind++]); } } } else { while (ind<=i){ fenwik.update(barr[ind++]); } } } cout<<ans<<endl; } }

Compilation message (stderr)

money.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
money.cpp: In member function 'void BIT::update(int)':
money.cpp:38:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for (; node<fenwik.size(); node=node|(node+1)) fenwik[node]++;
      |          ~~~~^~~~~~~~~~~~~~
money.cpp: In function 'void compress(std::vector<int>&)':
money.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for (int i = 0; i < arr.size(); i++){
      |                  ~~^~~~~~~~~~~~
money.cpp:61:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |  for (int i = 0; i < arr.size(); ++i)
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...