编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#47199 #1022. jwp的排队难题 Compile Error 0 0 ms 0 K C++ / 562 B 计试001陈子鹏 2021-03-04 9:07:26
显示原始代码
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;

struct node {
    int a, b;
} tour[100050];

bool cmp(const node &t1, const node &t2) { return t1.a * t2.b > t1.b * t2.a; }

int n, time;
LL ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &tour[i].a, &tour[i].b);
    }
    sort(tour, tour + n, cmp);
    for (int i = 0; i < n; i++) {
        time += tour[i].b;
        ans += time * tour[i].a;
    }
    cout << ans;
    return 0;
}

编译信息

/sandbox/1/a.cpp:18:8: error: 'int time' redeclared as different kind of symbol
 int n, time;
        ^~~~
In file included from /usr/include/pthread.h:24,
                 from /usr/include/x86_64-linux-gnu/c++/8/x32/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/8/x32/bits/gthr.h:148,
                 from /usr/include/c++/8/ext/atomicity.h:35,
                 from /usr/include/c++/8/bits/ios_base.h:39,
                 from /usr/include/c++/8/ios:42,
                 from /usr/include/c++/8/ostream:38,
                 from /usr/include/c++/8/iostream:39,
                 from /sandbox/1/a.cpp:1:
/usr/include/time.h:75:15: note: previous declaration 'time_t time(time_t*)'
 extern time_t time (time_t *__timer) __THROW;
               ^~~~
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:24:3: error: 'scanf' was not declared in this scope
   scanf("%d%d", &tour[i].a, &tour[i].b);
   ^~~~~
/sandbox/1/a.cpp:24:3: note: suggested alternative: 'wscanf'
   scanf("%d%d", &tour[i].a, &tour[i].b);
   ^~~~~
   wscanf
/sandbox/1/a.cpp:29:8: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   time += tour[i].b;
   ~~~~~^~~~~~~~~~~~
/sandbox/1/a.cpp:29:19: error: assignment of read-only location 'time'
   time += tour[i].b;
                   ^
/sandbox/1/a.cpp:30:15: error: invalid operands of types 'time_t(time_t*) throw ()' {aka 'long long int(long long int*)'} and 'int' to binary 'operator*'
   ans += time * tour[i].a;
          ~~~~~^~~~~~~~~~~