제출 #315342

#제출 시각아이디문제언어결과실행 시간메모리
315342Dymo거래 (IZhO13_trading)C++14
100 / 100
481 ms18480 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define endl "\n" const ll maxn=5e5+50; const ll mod =1e9+7; const ll base=113; ll st[4*maxn]; ll la[4*maxn]; void dosth(ll id,ll left,ll right) { if (left==right||la[id]==0) return; ll kc=(left+right)/2+1-left; st[id*2]=max(st[id*2],la[id]); la[id*2]=max(la[id*2],la[id]); la[id*2+1]=max(la[id*2+1],la[id]+kc); st[id*2+1]=max(st[id*2+1],la[id]+kc); la[id]=0; } void update(ll id,ll left,ll right,ll x,ll y,ll val) { dosth(id,left,right); if (x>right||y<left) return ; if (x<=left&&y>=right) { st[id]=max(st[id],val+left-x); la[id]=max(la[id],val+left-x); dosth(id,left,right); return ; } ll mid=(left+right)/2; update(id*2,left,mid, x, y,val); update(id*2+1,mid+1, right, x, y, val); } ll get(ll id,ll left,ll right,ll x ) { dosth(id,left,right); if (x>right||x<left) return 0; if (left==right) { /* if (x==5) { cout <<st[id]<<endl; }*/ return st[id]; } ll mid=(left+right)/2; return max(get(id*2,left,mid, x ), get(id*2+1, mid+1, right, x )); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen("GIDDY.inp", "r")) { freopen("GIDDY.inp", "r", stdin); freopen("GIDDY.out", "w", stdout) ; } ll n, m; cin>>n>>m ; for (int i=1;i<=m;i++) { ll x, y, p; cin>>x>> y>>p; update(1,1,n,x,y,p); } for (int i=1;i<=n;i++) { cout <<get(1,1,n,i)<<" "; } }

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

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