제출 #345143

#제출 시각아이디문제언어결과실행 시간메모리
345143RakhmandBigger segments (IZhO19_segments)C++14
0 / 100
1 ms512 KiB
// // A.cpp // torelax // // Created by Rakhman on 1/5/21. // #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <queue> #include <cmath> #include <cstdlib> #include <ctime> #include <cassert> #include <iterator> #define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0); #define S second #define F first #define pb push_back #define nl '\n' #define NL cout << '\n'; #define EX exit(0) #define all(s) s.begin(), s.end() #define no_answer {cout << "NO"; exit(0);} #define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k) const long long mxn = 1e6 + 110; const long long mnn = 3e3 + 2; const long long mod = 1e9 + 7; const long long inf = 1e18; const long long OO = 1e9 + 100; typedef long long llong; typedef unsigned long long ullong; using namespace std; llong n, b[mxn], pr[mxn], mx[mxn], dp[mxn]; int main() { cin >> n; for(int i = 1; i <= n; i++){ cin >> b[i]; pr[i] = pr[i - 1] + b[i]; } vector<pair<llong, int> > v; v.push_back({0, 0}); for(int i = 1; i <= n; i++) { int x = upper_bound(v.begin(), v.end(), make_pair(pr[i], -1)) - v.begin(); if(x == v.size() || v[x].F > pr[i]) x--; dp[i] = dp[v[x].S] + 1; v.push_back({2 * pr[i] - pr[v[x].S], i}); } cout << dp[n]; }

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

segments.cpp: In function 'int main()':
segments.cpp:65:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         if(x == v.size() || v[x].F > pr[i]) x--;
      |            ~~^~~~~~~~~~~
#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...