제출 #877104

#제출 시각아이디문제언어결과실행 시간메모리
877104auslanderBigger segments (IZhO19_segments)C++17
0 / 100
1 ms2652 KiB
#include <iostream> #include <algorithm> #include <math.h> #include <sstream> #include <string> #include <iomanip> #include <queue> #include <stack> #include <deque> #include <set> #include <map> #include <vector> #include <iterator> using namespace std; //defines #define ll long long #define usg unsigned #define kap map #define print(x, n) for(int for_loop = 0; for_loop < n; for_loop++){cout<<x[for_loop]<<' ';}cout<<endl; #define read(x, n) for(int for_loop = 0; for_loop < n; for_loop++){cin>>x[for_loop];} #define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ratdig(x) cout << fixed << setprecision(x); #define xfixdig(x) cout << setprecision(x); #define multi int t; cin>>t; presolve(); while(t--) solve() #define single presolve(); solve(); return 0 #define rev(x) reverse(x.begin(), x.end()) #define all(x) x.begin(), x.end() //functions void yn(bool b) { if (b) { cout << "YES\n"; return; } cout << "NO\n"; } ll gcd(ll a, ll b) { if (a == 0) return b; if (b == 0) return a; return gcd(b % a, a); } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } string to2(ll a) { string r = ""; for (ll i = a; i > 0; ) { ll k = i % 2; i /= 2; char c = k + 48; r += c; } if (a == 0) { r = "0"; } rev(r); return r; } ll binpow(ll a, ll b, ll mod = -1) { ll ans = 1; while (b) { if ((b & 1) == 1) { ans *= a; if (mod != -1) ans %= mod; } b >>= 1; a *= a; if (mod != -1) a %= mod; } return ans; } //body void presolve() { } ll arr[200005]; ll pref[200005]; void solve() { ll i, j, n, m, k, s, t, x, y; cin >> n; for (i = 0; i < n; i++) cin >> arr[i]; ll p = arr[0]; k = 0; vector<ll>st; vector<ll>::iterator it; ll res = 1; j = 0; for (i = 1; i < n; i++) { k += arr[i]; pref[j] = k; if (k >= p) { res++; it = upper_bound(all(st), (k - p) / 2); j = it - st.begin() - 1; p = k - pref[j]; st.erase(all(st)); k = 0; j = 0; } else { j++; st.push_back(k); } } cout << res << endl; } int main() { speed; single; multi; return 0; }

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

segments.cpp: In function 'void solve()':
segments.cpp:103:14: warning: unused variable 'm' [-Wunused-variable]
  103 |  ll i, j, n, m, k, s, t, x, y;
      |              ^
segments.cpp:103:20: warning: unused variable 's' [-Wunused-variable]
  103 |  ll i, j, n, m, k, s, t, x, y;
      |                    ^
segments.cpp:103:23: warning: unused variable 't' [-Wunused-variable]
  103 |  ll i, j, n, m, k, s, t, x, y;
      |                       ^
segments.cpp:103:26: warning: unused variable 'x' [-Wunused-variable]
  103 |  ll i, j, n, m, k, s, t, x, y;
      |                          ^
segments.cpp:103:29: warning: unused variable 'y' [-Wunused-variable]
  103 |  ll i, j, n, m, k, s, t, x, y;
      |                             ^
#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...