Submission #634975

#TimeUsernameProblemLanguageResultExecution timeMemory
634975minhcool즐거운 채소 기르기 (JOI14_growing)C++17
45 / 100
1076 ms704 KiB
//#include "ramen.h" #include<bits/stdc++.h> using namespace std; //#define int long long #define fi first #define se second #define pb push_back //#define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 1e5 + 5; const int oo = 1e18 + 7, mod = 1e9 + 7; int n, a[N]; void process(){ cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; int answer = 0; for(int i = 1; i <= n; i++){ int tol1 = 0, tol2 = 0; for(int j = 1; j < i; j++) tol1 += (a[j] > a[i]); for(int j = i + 1; j <= n; j++) tol2 += (a[j] > a[i]); answer += min(tol1, tol2); } cout << answer; } signed main(){ ios_base::sync_with_stdio(0); process(); }

Compilation message (stderr)

growing.cpp:19:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...