# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
283785 | 2020-08-26T07:19:14 Z | erd1 | Ancient Books (IOI17_books) | C++14 | 1 ms | 384 KB |
#include "books.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() typedef pair<int, int> pii; typedef long long lld; typedef long double ld; template<typename Iter> ostream& outIt(ostream& out, Iter b, Iter e){ for(Iter i = b; i != e; ++i) out << (i == b?"":" ") << *i; return out; } template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> p){ return out << '(' << p.ff << ", " << p.ss << ')'; } template<typename T> ostream& operator<<(ostream& out, vector<T> v){ return outIt(out << '[', all(v)) << ']'; } vector<pii> cs; long long minimum_walk(vector<int> p, int s) { lld ans = 0; int pmin = INT_MAX, pmax = INT_MIN; for(int i = 0; i < p.size(); i++)if(p[i] != i)ans += abs(p[i]-i), cs.pb({min(i, p[i]), max(i, p[i])}), pmin = min(pmin, i), pmax = max(pmax, i); if(ans == 0)return 0; sort(all(cs)); ans += 2 * (max(0, pmin - s) + max(0, s - pmax)); int r = cs.front().ff; for(int i = 0; i < cs.size(); i++){ ans += 2*max(0, r-cs[i].ff); r = max(r, cs[i].ss); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '6', found: '10' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '6', found: '10' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '6', found: '10' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | 3rd lines differ - on the 1st token, expected: '3304', found: '469696' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '6', found: '10' |
2 | Halted | 0 ms | 0 KB | - |