답안 #1081448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081448 2024-08-30T05:02:04 Z veehj Fish 2 (JOI22_fish2) C++17
13 / 100
4000 ms 2140 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (ll) a.size()
#define all(x) (x).begin(), (x).end()
ll n, q;
vector<ll> a, ans;

void f(ll l, ll r){
  if(l==r){
    ans[l]=1;
    return;
  }
  ll mx=0, mxp=0;
  for(ll i=l; i<=r; i++){
    if(mx<a[i]) mx=a[i], mxp=i;
  }
  ans[mxp]=1;
  ll cnt=0;
  for(ll i=l; i<mxp; i++) cnt+=a[i];
  if(cnt>=mx) f(l, mxp-1);
  cnt=0;
  for(ll i=mxp+1; i<=r; i++) cnt+=a[i];
  if(cnt>=mx) f(mxp+1, r);
}

int main() {
  cin >> n;
  a.assign(n, -1);
  for(ll i=0; i<n; i++) cin >> a[i];
  ans.assign(n, 0);
  cin >> q;
  while(q--){
    ll t, x, y; cin >> t >> x >> y;
    if(t==1) a[x-1]=y;
    else{
      ans.assign(n, 0);
      f(x-1, y-1);
      ll cnt=0;
      for(auto& u : ans) cnt+=u;
      cout << cnt << endl;
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 23 ms 2140 KB Output is correct
3 Correct 13 ms 1884 KB Output is correct
4 Correct 18 ms 2000 KB Output is correct
5 Correct 14 ms 2020 KB Output is correct
6 Correct 27 ms 1876 KB Output is correct
7 Correct 9 ms 1884 KB Output is correct
8 Correct 26 ms 1976 KB Output is correct
9 Correct 9 ms 1884 KB Output is correct
10 Correct 23 ms 1996 KB Output is correct
11 Correct 12 ms 1880 KB Output is correct
12 Correct 11 ms 2000 KB Output is correct
13 Correct 11 ms 1992 KB Output is correct
14 Correct 271 ms 1996 KB Output is correct
15 Correct 282 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 23 ms 2140 KB Output is correct
23 Correct 13 ms 1884 KB Output is correct
24 Correct 18 ms 2000 KB Output is correct
25 Correct 14 ms 2020 KB Output is correct
26 Correct 27 ms 1876 KB Output is correct
27 Correct 9 ms 1884 KB Output is correct
28 Correct 26 ms 1976 KB Output is correct
29 Correct 9 ms 1884 KB Output is correct
30 Correct 23 ms 1996 KB Output is correct
31 Correct 12 ms 1880 KB Output is correct
32 Correct 11 ms 2000 KB Output is correct
33 Correct 11 ms 1992 KB Output is correct
34 Correct 271 ms 1996 KB Output is correct
35 Correct 282 ms 1884 KB Output is correct
36 Correct 1436 ms 2000 KB Output is correct
37 Correct 350 ms 2132 KB Output is correct
38 Correct 399 ms 1884 KB Output is correct
39 Correct 365 ms 1880 KB Output is correct
40 Correct 439 ms 1992 KB Output is correct
41 Correct 799 ms 1880 KB Output is correct
42 Correct 1047 ms 1884 KB Output is correct
43 Correct 266 ms 1884 KB Output is correct
44 Correct 222 ms 1996 KB Output is correct
45 Correct 826 ms 1996 KB Output is correct
46 Correct 741 ms 1996 KB Output is correct
47 Correct 464 ms 1884 KB Output is correct
48 Correct 108 ms 1884 KB Output is correct
49 Correct 319 ms 2000 KB Output is correct
50 Execution timed out 4085 ms 1884 KB Time limit exceeded
51 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 23 ms 2140 KB Output is correct
3 Correct 13 ms 1884 KB Output is correct
4 Correct 18 ms 2000 KB Output is correct
5 Correct 14 ms 2020 KB Output is correct
6 Correct 27 ms 1876 KB Output is correct
7 Correct 9 ms 1884 KB Output is correct
8 Correct 26 ms 1976 KB Output is correct
9 Correct 9 ms 1884 KB Output is correct
10 Correct 23 ms 1996 KB Output is correct
11 Correct 12 ms 1880 KB Output is correct
12 Correct 11 ms 2000 KB Output is correct
13 Correct 11 ms 1992 KB Output is correct
14 Correct 271 ms 1996 KB Output is correct
15 Correct 282 ms 1884 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Execution timed out 4090 ms 2004 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 23 ms 2140 KB Output is correct
3 Correct 13 ms 1884 KB Output is correct
4 Correct 18 ms 2000 KB Output is correct
5 Correct 14 ms 2020 KB Output is correct
6 Correct 27 ms 1876 KB Output is correct
7 Correct 9 ms 1884 KB Output is correct
8 Correct 26 ms 1976 KB Output is correct
9 Correct 9 ms 1884 KB Output is correct
10 Correct 23 ms 1996 KB Output is correct
11 Correct 12 ms 1880 KB Output is correct
12 Correct 11 ms 2000 KB Output is correct
13 Correct 11 ms 1992 KB Output is correct
14 Correct 271 ms 1996 KB Output is correct
15 Correct 282 ms 1884 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Execution timed out 4070 ms 2000 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 23 ms 2140 KB Output is correct
23 Correct 13 ms 1884 KB Output is correct
24 Correct 18 ms 2000 KB Output is correct
25 Correct 14 ms 2020 KB Output is correct
26 Correct 27 ms 1876 KB Output is correct
27 Correct 9 ms 1884 KB Output is correct
28 Correct 26 ms 1976 KB Output is correct
29 Correct 9 ms 1884 KB Output is correct
30 Correct 23 ms 1996 KB Output is correct
31 Correct 12 ms 1880 KB Output is correct
32 Correct 11 ms 2000 KB Output is correct
33 Correct 11 ms 1992 KB Output is correct
34 Correct 271 ms 1996 KB Output is correct
35 Correct 282 ms 1884 KB Output is correct
36 Correct 1436 ms 2000 KB Output is correct
37 Correct 350 ms 2132 KB Output is correct
38 Correct 399 ms 1884 KB Output is correct
39 Correct 365 ms 1880 KB Output is correct
40 Correct 439 ms 1992 KB Output is correct
41 Correct 799 ms 1880 KB Output is correct
42 Correct 1047 ms 1884 KB Output is correct
43 Correct 266 ms 1884 KB Output is correct
44 Correct 222 ms 1996 KB Output is correct
45 Correct 826 ms 1996 KB Output is correct
46 Correct 741 ms 1996 KB Output is correct
47 Correct 464 ms 1884 KB Output is correct
48 Correct 108 ms 1884 KB Output is correct
49 Correct 319 ms 2000 KB Output is correct
50 Execution timed out 4085 ms 1884 KB Time limit exceeded
51 Halted 0 ms 0 KB -