답안 #782684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782684 2023-07-14T07:33:38 Z math_rabbit_1028 즐거운 채소 기르기 (JOI14_growing) C++14
30 / 100
1000 ms 908 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, arr[303030];
ll lt[303030], rt[303030];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> arr[i];

    vector<int> v;
    for (int i = 1; i <= n; i++) {
        lt[i] = lt[i - 1] + (v.end() - upper_bound(v.begin(), v.end(), arr[i]));
        v.push_back(arr[i]);
        sort(v.begin(), v.end());
    }

    v.clear();
    for (int i = n; i >= 1; i--) {
        rt[i] = rt[i + 1] + (v.end() - upper_bound(v.begin(), v.end(), arr[i]));
        v.push_back(arr[i]);
        sort(v.begin(), v.end());
    }

    ll ans = 1e18;
    for (int i = 0; i <= n; i++) ans = min(ans, lt[i] + rt[i + 1]);
    cout << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 908 KB Time limit exceeded
2 Halted 0 ms 0 KB -