제출 #84634

#제출 시각아이디문제언어결과실행 시간메모리
84634farukkastamonuda거래 (IZhO13_trading)C++14
100 / 100
477 ms45684 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define lo long long #define inf 1000000000 #define md 1000000007 #define pb push_back #define li 300005 #define ii pair<int,int> #define mid (start+end)/2 using namespace std; int n,m,l,r,x,tree[li*4],lazy[li*4]; void push(int node,int start,int end){ if(lazy[node]==0) return ; tree[node]=max(tree[node],lazy[node]); if(start!=end){ lazy[node*2]=max(lazy[node*2],lazy[node]-(end-mid)); lazy[node*2+1]=max(lazy[node*2+1],lazy[node]); } lazy[node]=0; } void update(int node,int start,int end,int l,int r,int val){ push(node,start,end); if(start>end || start>r || end<l) return ; if(start>=l && end<=r){ lazy[node]=max(lazy[node],val-(r-end)); push(node,start,end); return ; } update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val); tree[node]=max(tree[node*2],tree[node*2+1]); } int query(int node,int start,int end,int l,int r){ if(start>end || start>r || end<l) return -inf; push(node,start,end); if(start>=l && end<=r) return tree[node]; return max(query(node*2,start,mid,l,r),query(node*2+1,mid+1,end,l,r)); } int main(){ scanf("%d %d",&n,&m); for(int i=1;i<=m;i++){ scanf("%d %d %d",&l,&r,&x); update(1,1,n,l,r,x+r-l); } for(int i=1;i<=n;i++){ printf("%d ",query(1,1,n,i,i)); } return 0; }

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

trading.cpp: In function 'int main()':
trading.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
trading.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&l,&r,&x);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...