Submission #1010511

# Submission time Handle Problem Language Result Execution time Memory
1010511 2024-06-29T07:29:14 Z mychecksedad Fish 3 (JOI24_fish3) C++17
0 / 100
2000 ms 6388 KB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;


int  n, q;
ll D, C[N], b[N];
void solve(){
  cin >> n >> D;
  for(int i = 1; i <= n; ++i) cin >> C[i];
  cin >> q;
  for(int i = 1; i <= q; ++i){
    int l, r; cin >> l >> r;
    int ans = 0;
    b[r] = C[r];
    for(int x = r - 1; x >= l; --x){
      if(C[x] <= b[x + 1]){
        b[x] = C[x];
      }else{
        b[x] = C[x] % D;
        if(b[x] > b[x + 1]){
          ans = -1;
          break;
        }
        ans += C[x] / D - (b[x + 1] - b[x]) / D;
        b[x] += (b[x + 1] - b[x]) / D * D;
      }
    }
    // for(int j = l; j <= r; ++j) cout << b[j] << ' ';
    cout << ans << '\n';
  }
}


int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tt = 1, aa;
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  while(tt--){
    solve();
    en;
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  return 0;
} 

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:44:15: warning: unused variable 'aa' [-Wunused-variable]
   44 |   int tt = 1, aa;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2049 ms 5868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1227 ms 6388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2065 ms 5108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -