제출 #1128230

#제출 시각아이디문제언어결과실행 시간메모리
1128230duyhoanhoTwo Antennas (JOI19_antennas)C++20
2 / 100
3092 ms4420 KiB
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fi first
#define se second

using namespace std;
const int N = 2e5 + 10;
int n, h[N], a[N], b[N], q;

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  if(fopen("task.inp","r")){
      freopen("task.inp","r",stdin);
      freopen("task.out","w",stdout);
  }
  #define task ""
  if(fopen(task".inp","r")){
      freopen(task".inp","r",stdin);
      freopen(task".out","w",stdout);
  }

  cin >> n;

  for(int i = 1; i <= n; i++) cin >> h[i] >> a[i] >> b[i];

  cin >> q;
  while(q--){
    int l, r;
    cin >> l >> r;
    int ans = -1;
    for(int i = l; i < r; i++){
      for(int j = i + 1; j <= r; j++){
        if(i + a[i] <= j && j <= i + b[i] && j - a[j] >= i && i >= j - b[j]) ans = max(ans, abs(h[i] - h[j]));
      }
    }
    cout<<ans<<"\n";
  }
}

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

antennas.cpp: In function 'int32_t main()':
antennas.cpp:16:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |       freopen("task.inp","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
antennas.cpp:17:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |       freopen("task.out","w",stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
antennas.cpp:21:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |       freopen(task".inp","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
antennas.cpp:22:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |       freopen(task".out","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...