Submission #118435

# Submission time Handle Problem Language Result Execution time Memory
118435 2019-06-19T03:24:30 Z str0ct None (KOI18_arrowH) C++14
0 / 100
2 ms 1152 KB
#include<bits/stdc++.h>
using namespace std;
long long color[101010],opt[101010],sum;
typedef struct{
    long long ipt,w;
}nd;
bool operator<(nd a,nd b){
    return a.w<b.w;
}
nd arr[101010];
int main(){
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
        scanf("%lld%lld",&arr[i].w,&arr[i].ipt);
    memset(color,-1,sizeof(color));
    for(int i=0;i<N;i++){
        if(color[arr[i].ipt]!=-1)
            opt[i]=arr[i].w-color[arr[i].ipt];
        color[arr[i].ipt]=arr[i].w;
    }
    memset(color,-1,sizeof(color));
    for(int i=N-1;i>=0;i--){
        if(color[arr[i].ipt]!=-1&&(opt[i]==0||opt[i]>color[arr[i].ipt]-arr[i].w))
            opt[i]=color[arr[i].ipt]-arr[i].w;
        color[arr[i].ipt]=arr[i].w;
    }
    for(int i=0;i<N;i++)
        sum+=opt[i];
    printf("%lld",sum);
}

Compilation message

arrow.cpp: In function 'int main()':
arrow.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
arrow.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld",&arr[i].w,&arr[i].ipt);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -