답안 #682788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
682788 2023-01-17T02:44:33 Z Paul_Liao_1457 Fire (JOI20_ho_t5) C++17
13 / 100
206 ms 9940 KB
//記得跳題
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<tuple>
 
#define ll long long
#define LL __int128_t
#define DB double
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (ll)(1e9)
#define MOD (ll)(1e9+7)
#define F first
#define S second
#define endl "\n"
#define AC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
using namespace std;
 
template<class T> using PQ=priority_queue<T,vector<T>,less<T> >;
 
void file(){
    freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin);
    freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout);
}
 
int s[200005],seg[800005];
 
void build(int id,int l,int r){
    if(l==r){
        seg[id]=s[l]; return;
    }
    int mid=(l+r)>>1;
    build(id*2,l,mid);
    build(id*2+1,mid+1,r);
    seg[id]=max(seg[id*2],seg[id*2+1]);
}
 
int ask(int id,int l,int r,int L,int R){
    if(l>R||r<L) return 0;
    if(L<=l&&r<=R) return seg[id];
    int mid=(l+r)>>1;
    return max(ask(id*2,l,mid,L,R),ask(id*2+1,mid+1,r,L,R));
}

int t[200005],l[200005],r[200005];
ll pre[200005];
 
signed main(){
    AC;
    int n,q; cin>>n>>q;
    FOR(i,1,n+1) cin>>s[i];
    build(1,1,n);
    FOR(i,0,q){
        cin>>t[i]>>l[i]>>r[i];
    }
    FOR(i,1,n+1){
        pre[i]=pre[i-1]+ask(1,1,n,i-t[0],i);
    }
    FOR(i,0,q){
        if(l[i]==r[i]){
            cout<<ask(1,1,n,l[i]-t[i],l[i])<<endl;
        }
        else cout<<pre[r[i]]-pre[l[i]-1]<<endl;
    }
}
 
 
/*
 
 */

Compilation message

ho_t5.cpp: In function 'void file()':
ho_t5.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t5.cpp:38:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 117 ms 9700 KB Output is correct
3 Correct 99 ms 9764 KB Output is correct
4 Correct 119 ms 9868 KB Output is correct
5 Correct 149 ms 9816 KB Output is correct
6 Correct 129 ms 9692 KB Output is correct
7 Correct 154 ms 9908 KB Output is correct
8 Correct 128 ms 9864 KB Output is correct
9 Correct 115 ms 9912 KB Output is correct
10 Correct 139 ms 9776 KB Output is correct
11 Correct 106 ms 9940 KB Output is correct
12 Correct 105 ms 9676 KB Output is correct
13 Correct 130 ms 9804 KB Output is correct
14 Correct 120 ms 9720 KB Output is correct
15 Correct 116 ms 9764 KB Output is correct
16 Correct 123 ms 9780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 199 ms 8920 KB Output is correct
3 Correct 162 ms 9692 KB Output is correct
4 Correct 157 ms 9768 KB Output is correct
5 Correct 180 ms 9616 KB Output is correct
6 Correct 152 ms 9688 KB Output is correct
7 Correct 164 ms 9736 KB Output is correct
8 Correct 193 ms 9804 KB Output is correct
9 Correct 169 ms 9688 KB Output is correct
10 Correct 206 ms 9532 KB Output is correct
11 Correct 172 ms 9832 KB Output is correct
12 Correct 183 ms 9636 KB Output is correct
13 Correct 167 ms 9824 KB Output is correct
14 Correct 154 ms 9628 KB Output is correct
15 Correct 191 ms 9720 KB Output is correct
16 Correct 159 ms 9564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 94 ms 7992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -