QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#628157#9266. Dynamic Traffic with MegaFonucup-team3474Compile Error//C++20579b2024-10-10 18:57:062024-10-10 18:57:06

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 18:57:06]
  • 评测
  • [2024-10-10 18:57:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];



int main(){
    memset(tr1,-0x3f,sizeof tr1);
    memset(tr2,-0x3f,sizeof tr2);
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    vector<ll> v;
    
    for(int i=1;i<=n;i++){
        if(a[i]>=0) v.push_back(a[i]);
        else{
            if(!v.size()||v.back()>=0) v.push_back(a[i]);
        }    
    }
    ll ans=0;
    for(int i=1;i<v.size();i++) ans+=max(v[i],v[i-1]);
    cout<<ans<<endl;
}

详细

answer.code: In function ‘int main()’:
answer.code:12:12: error: ‘tr1’ was not declared in this scope
   12 |     memset(tr1,-0x3f,sizeof tr1);
      |            ^~~
answer.code:13:12: error: ‘tr2’ was not declared in this scope
   13 |     memset(tr2,-0x3f,sizeof tr2);
      |            ^~~
answer.code:15:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
      |                           ~~~~~^~~~~~~~~~~~~~