제출 #1105081

#제출 시각아이디문제언어결과실행 시간메모리
1105081VinhLuu송금 (JOI19_remittance)C++17
100 / 100
257 ms37316 KiB
#include <bits/stdc++.h>
#define int long long
#define ll long long
using namespace std;

const int N = 1e6 + 5;
const int oo = 1e9;


int c[N], n, a[N], b[N];
bool f[N];

int st[N << 1];

void update(int i){
  i += n - 1;
  while(i > 1){
    i /= 2;
    if(c[st[i << 1]] >= c[st[i << 1|1]]) st[i] = st[i << 1];
    else st[i] = st[i << 1|1];
  }
}

signed main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define task "v"
  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 >> a[i] >> b[i];
  }

  for(int time = 0; time <= 30; time ++){
    for(int i = 1; i <= n; i ++) if(a[i] >= b[i]){
      int val = (a[i] - b[i]) / 2;
      a[i] -= 2 * val;
      int nx = (i == n ? 1 : i + 1);
      a[nx] += val;
    }
  }

  bool ff = true, gg = true, vv = true;
  for(int i = 1; i <= n; i ++){
    if(a[i] < b[i]){
      cout << "No\n";
      return 0;
    }
    if(a[i] != b[i]) ff = false;
    if(a[i] == b[i]) vv = false;
    if(a[i] > 1) gg = false;
  }
  if(ff){
    cout << "Yes\n";
    return 0;
  }

  if(!gg && vv){
    cout << "Yes\n";
  }else cout << "No\n";

}

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

remittance.cpp: In function 'int main()':
remittance.cpp:28:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     freopen(task ".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:29:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     freopen(task ".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...