제출 #1121621

#제출 시각아이디문제언어결과실행 시간메모리
1121621E_rKGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false) #define pb push_back #define ppb pop_back #define fi first #define se second #define sp " " #define endl "\n" #define mod 1000000007 #define MAXN 200005 #define MAXM 1000005 #define inf 1e18 #define INF 0x3f #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define debug(x) for(auto& a: x) cout << a << " " using namespace std; typedef long long int lo; lo arr[MAXN],dad[MAXN],sz[MAXN]; lo n,m,k; vector<pair<lo,lo>> v[505]; string s; void solve() { cin >> n; lo mx=0, mxind=0; for (int i = 0; i < n; ++i) { cin >> arr[i]; if(mx <= arr[i]){ mxind = i; mx = arr[i]; } } vector<lo> eklencek(n+1,0); for (int i = 1; i <= mxind; ++i) { if(arr[i] <= arr[i-1]+eklencek[i-1]){ eklencek[i] = arr[i-1]-arr[i]+eklencek[i-1]+1; } } for (int i = n-2; i >= mxind; i--) { if(arr[i] <= arr[i+1]+eklencek[i+1]){ eklencek[i] = arr[i+1]-arr[i]+eklencek[i+1]+1; } } // debug(eklencek); // cout << endl; lo ans = 0; lo ekle = 0; for (int i = 0; i < eklencek.size(); ++i) { if(eklencek[i] == 0 and i != mxind){ ans += ekle; ekle=0; } else { ekle = max(ekle,eklencek[i]); } } cout << ans << endl; } int main() { // cout << fixed << setprecision(12); // freopen("snowboots.in","r",stdin); // freopen("snowboots.out","w",stdout); fast; int t = 1; // cin >> t; while(t--) { solve(); } // cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void solve()':
Main.cpp:54:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int i = 0; i < eklencek.size(); ++i)
      |                     ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...