QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687495#9528. New Energy VehiclebulingCompile Error//C++143.0kb2024-10-29 19:21:582024-10-29 19:22:00

Judging History

This is the latest submission verdict.

  • [2024-10-29 19:22:00]
  • Judged
  • [2024-10-29 19:21:58]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define lll i << 1
#define rrr i << 1 | 1


//
 #define ll long long
 #define int long long

	#define ld long double
	#define rint register int
	#define inv inline void
	#define ini inline int
    inline int read()
    {
        int sum=0;
        char ch=getchar();
        while(ch>'9'||ch<'0') ch=getchar();
        while(ch>='0'&&ch<='9') sum=sum*10+ch-48,ch=getchar();
        return sum;
    }//读入优化

    
    inline void print(int x){
        if(!x){
            putchar('0');
            return;
        }
        int num[22],siz=0,px=x;
        while(px){
            siz++;
            num[siz]=px%10;
            px/=10;
        }
        while(siz){
            putchar(num[siz]+'0');
            siz--;
        }
    }   //快速输出
      
    long long max(long long a,long long b)
    {
       return a>b?a:b;
    }
      
    long long min(long long a,long long b)
    {
       return a<b?a:b;
    }
     
      
    const int N=1e6+7;
    const int N2=2e5+5; 
    int mod=9999973;
    //int Mod=1e15+7;
    const int INF=2e17;
  	const double eps=1e-10;
 	const double PI=3.1415926535;
//priority_queue<int , vector<int >, greater<int >> q;
//priority_queue<int > q;
//map<string ,int>mp,mmp;
 //typedef pair<int ,int > PII;
//stack < PII > p;
 
//queue<int > q;
//char s1[2020],s2[2020];
//vector<vector<int>> c(n+13,vector<int>(m+3));
//map<int,int>mp;
 
//priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >q[1001][1001],p;
 //a.erase(unique(a.begin(), a.end()), a.end());
//char p,q;
//char s[N];
//deque<int > q;
//queue<int> q;
using ull = unsigned long long;
//ull mod=212370440130137957ll;

int ma,mi;
int  n,m,t;

//int a[N],b[N],c[N],f[N];

//
//struct node
//{
//	
//	int y,z,x;
//	
//}p[N];
//inline bool cmp(node w,node v)
//{
//	
//	return w.x>v.x;	
//}

//
//int fx[5]={-1,0,0,1};
//int fy[5]={0,-1,1,0};



signed main()
{
	std::ios::sync_with_stdio(false);//取消cin与stdin同步,加速读入 
	cin.tie(0);cout.tie(0);
 	
 	t=1;
 	string s;
	cin>>t;

	while(t--)
	{
		int res=0,tt=0,ans=0,k,fa=0;
		ma=0,mi=2e17;
		map<int,int> mp;
		multiset<int> se;
		cin>>n>>m;
		vector<int> a(n+3),b(m+3),c(m+3);
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			ans+=a[i];
		}
		tt=ans;
		b[m+1]=2e17;
		for(int i=1;i<=m;i++)
		{
			int x,y;
			cin>>b[i]>>c[i];
			
		}
		for(int i=1;i<=m+1;i++)
		{
			if(ans<b[i]-b[i-1])
			{
				if(ans)
					res=ans+b[i-1];
				ans=0;
			}
			else
			{
				
				if((tt-ans+b[i]-b[i-1])<=a[c[i]])
					ans=tt;
				else
				{
					if(b[i]-mp[c[i]]<a[c[i]])
					{
						ans-=b[i]-b[i-1];
						ans+=(b[i]-mp[c[i]];
					}
					else
					{
						ans-=b[i]-b[i-1];
						ans+=a[c[i]];
					}
					
					
						
					//ans+=a[c[i]];
				}	
				mp[c[i]]=b[i];
			}
		}
		//if(ans)
		//	res=ans+b[m];
		cout<<res;
		cout<<"\n";
	}
    return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:152:68: error: expected ‘)’ before ‘;’ token
  152 |                                                 ans+=(b[i]-mp[c[i]];
      |                                                      ~             ^
      |                                                                    )