Submission #257202

#TimeUsernameProblemLanguageResultExecution timeMemory
257202MarlovStudentsko (COCI14_studentsko)C++14
0 / 100
2 ms384 KiB
/* Code by @marlov */ #include <iostream> #include <fstream> #include <string> #include <sstream> #include <vector> #include <string> #include <cmath> #include <algorithm> #include <iomanip> #include <utility> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <stack> #include <queue> #include <iterator> using namespace std; typedef long long ll; typedef pair<int,int> pi; #define maxN 5005 int N,K; pi arr[maxN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>N>>K; for(int i=0;i<N;i++){ cin>>arr[i].first; arr[i].second=i; } sort(arr,arr+N); vector<int> ls; for(int i=0;i<N;i++){ int cv=arr[i].second; if(ls.empty()||cv>ls.back()){ ls.push_back(cv); }else{ *upper_bound(ls.begin(),ls.end(),cv)=cv; } } cout<<N-ls.size()<<'\n'; return 0; } /* stuff you should look for * int overflow, array bounds * special cases (n=1,n=0?) * do smth instead of nothing and stay organized */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...