蒟蒻用了老师教的代码,结果0分,还特意下了一个数据,运行之后也没问题,神犇看下有什么问题吗?
#include<iostream>
using namespace std;
struct ticket
{
int price,time;
bool used;
} a[100005];
int main()
{
int n,cnt,ans;
cin >> n;
int pos = 1;
for (int i = 1;i <= n;i++)
{
int op,price,time;
cin >> op >> price >> time;
if (!op)
{
ans += price;
cnt++;
a[cnt].price = price;
a[cnt].time = time + 45;
}
else
{
bool flag = false;
for (int j = pos;j <= cnt;j++)
{
if (price <= a[j].price && time <= a[j].time && !a[j].used)
{
a[j].used = true;
flag = true;
break;
}
if (time > a[j].time)
{
pos = j + 1;
}
}
if (!flag)
{
ans += price;
}
}
}
cout << ans << endl;
return 0;
}
悬赏关注1月~