제출 #1170479

#제출 시각아이디문제언어결과실행 시간메모리
1170479vyaductBouquet (EGOI24_bouquet)C++20
8 / 100
26 ms4936 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> oset;
 
void setIo(string in="", string out=""){
  if (!in.empty() && !out.empty()){
    freopen(in.c_str(), "r", stdin);
    freopen(out.c_str(), "w", stdout);
  }
  ios::sync_with_stdio(false);
  cin.tie(0);
}
 
#define all(c)      (c).begin(), (c).end()
#define sz(c)       (int)(c).size()
#define vt          vector
#define pb          push_back
#define F           first
#define S           second
#define pii         pair<int, int>
#define DEBUG       true
#define dbg(x)      if (DEBUG) cout << #x << " = " << x << ";\n";
#define dbg_vec(v)  if (DEBUG) cout << #v << " = { "; for (auto x: v) cout << x << " "; cout << "}\n";
#define mp          make_pair
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}

void solve(){
  int n; cin>>n;
  vt<pair<ll, ll>> A(n); // (l[i], r[i])
  for (int i=0;i<n;i++){
    cin>>A[i].F>>A[i].S;
  }

  vt<ll> dp(n, 1);
  for (int i=1;i<n;i++){
    int l=0, r=i-1-A[i].F;
    while(l<r){
      int m = l + (r-l+1)/2;
      if(m + A[m].S < i){
        l = m;
      } else {
        r = m-1;
      }
    }

    if (l + A[l].S < i) dp[i] = dp[l]+1;
  }
  cout << *max_element(all(dp)) << endl;
}

int main() {
  setIo();
  int tt=1; 
  // cin>>tt;
  while(tt--) solve();
  return 0;
} 

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

Main.cpp: In function 'void setIo(std::string, std::string)':
Main.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen(in.c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen(out.c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...