結果
| 問題 | 
                            No.1008 Bench Craftsman
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Strorkis
                         | 
                    
| 提出日時 | 2020-03-07 08:43:51 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 994 bytes | 
| コンパイル時間 | 704 ms | 
| コンパイル使用メモリ | 69,632 KB | 
| 実行使用メモリ | 5,632 KB | 
| 最終ジャッジ日時 | 2024-10-14 11:43:15 | 
| 合計ジャッジ時間 | 2,562 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 4 WA * 23 | 
ソースコード
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<ll> a(N); for (int i = 0; i < N; i++) cin >> a[i];
  vector<ll> v(N), w(M);
  for (int i = 0; i < M; i++) {
    int x; cin >> x >> w[i]; x--;
    v[x]++;
  }
  ll sow = 0;
  for (int i = 0; i < M; i++) sow += w[i];
  for (int i = 0; i < N; i++) a[i] = max(0LL, sow - a[i]);
  ll left = 0, right = 0;
  int col = 0, cor = 0;
  for (int i = 1; i < N; i++) {
    cor += v[i];
    right += v[i] * i;
  }
  if (a[0] != 0 && right == 0) {
    cout << -1 << "\n";
    return 0;
  }
  ll ans = a[0] ? (a[0]+right-1) / right : 0;
  for (int i = 1; i < N; i++) {
    if (a[i] == 0) continue;
    col += v[i-1];
    left += col;
    right -= cor;
    cor -= v[i];
    if (left + right == 0) {
      cout << -1 << "\n";
      return 0;
    }
    ans = max(ans, (a[i]+left+right-1) / (left+right));
  }
  cout << ans << "\n";
}
            
            
            
        
            
Strorkis