Submission #118433

#TimeUsernameProblemLanguageResultExecution timeMemory
118433str0ct화살표 그리기 (KOI18_arrowH)C++14
0 / 100
2 ms1152 KiB
#include<bits/stdc++.h> using namespace std; long long ipt[101010],w[101010],color[101010],opt[101010],sum; int main(){ int N; scanf("%d",&N); for(int i=0;i<N;i++) scanf("%lld%lld",&w[i],&ipt[i]); memset(color,-1,sizeof(color)); for(int i=0;i<N;i++){ if(color[ipt[i]]!=-1) opt[i]=w[i]-color[ipt[i]]; color[ipt[i]]=w[i]; } memset(color,-1,sizeof(color)); for(int i=N-1;i>=0;i--){ if(color[ipt[i]]!=-1&&(opt[i]==0||opt[i]>color[ipt[i]]-w[i])) opt[i]=color[ipt[i]]-w[i]; color[ipt[i]]=w[i]; } for(int i=0;i<N;i++) sum+=opt[i]; printf("%lld",sum); }

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
arrow.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&w[i],&ipt[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...