Submission #942029

#TimeUsernameProblemLanguageResultExecution timeMemory
942029TsaganaGroup Photo (JOI21_ho_t3)C++14
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define lb lower_bound #define ub upper_bound #define pb push_back #define mset multiset #define F first #define S second using namespace std; void solve () { int n; cin >> n; vector<int > v; int pos[5001]; for (int i = 1; i <= n; i++) { int x; cin >> x; v.pb(x); pos[x] = i; } int ans = 0; for (int i = 1; i < v.size(); i++) { if (v[i] != n && pos[v[i]] > pos[v[i]+1]) { int l = pos[v[i]+1]; int r = pos[v[i]]; for (int j = r-1; j > l; j--) { pos[v[j-1]]++; ans++; } pos[v[i]] = pos[v[i]+1]+1; } } cout << ans; } signed main(){IOS solve(); return 0;}

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:28:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for (int i = 1; i < v.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...
#Verdict Execution timeMemoryGrader output
Fetching results...