이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 200*1000+7;
int a[N];
int b[N];
int t[4*N];
int ind[4*N];
void build(int v,int l,int r){
if(l == r){
t[v] = a[l];
ind[l] = v;
return;
}
int m = (l+r)/2;
build(v*2,l,m);
build(v*2+1,m+1,r);
t[v] = min(t[v*2],t[v*2+1]);
}
void update(int v,int s,int e,int l,int r,int val){
if(l>r) return;
if(s == l && e == r){
if(t[v]>val) return;
if(s == e){
if(t[v] == a[l]) t[v] = b[l];
else t[v] = a[l];
return;
}
}
int m = (s+e)/2;
update(v*2,s,m,l,min(m,r),val);
update(v*2+1,m+1,e,max(l,m+1),r,val);
t[v] = min(t[v*2],t[v*2+1]);
}
int main(){
int n,k;
scanf("%d%d",&n,&k);
for(int i = 1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
build(1,1,n);
for(int i = 1;i<=k;i++){
int x;
scanf("%d",&x);
update(1,1,n,1,n,x);
}
long long ans = 0;
for(int i = 1;i<=n;i++){
ans+=t[ind[i]];
}
cout<<ans<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&k);
~~~~~^~~~~~~~~~~~~~
fortune_telling2.cpp:37:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int i = 1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~
fortune_telling2.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&x);
~~~~~^~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |