编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#100508 #1022. jwp的排队难题 Compile Error 0 0 ms 0 K C++ 11 / 573 B wrh123 2023-07-30 12:30:34
显示原始代码
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
long long sum, t;
struct tourist {
    int a, b;
    double w;
} p[N];
bool cmp(tourist x, tourist y) {
    if (x.w > y.w)
        return true;
    else
        return false;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &p[i].a, &p[i].b);
        p[i].w = p[i].a * 1.0 / p[i].b;
    }
    sort(p, p + n, cmp);
    for (int i = 0; i < n; i++) {
        t += p[i].b;
        sum += p[i].a * t;
    }
    printf("%lld", sum);

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:28:24: error: expected '}' at end of input
   28 |     printf("%lld", sum);
      |                        ^
/sandbox/1/a.cpp:17:12: note: to match this '{'
   17 | int main() {
      |            ^
/sandbox/1/a.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
/sandbox/1/a.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%d%d", &p[i].a, &p[i].b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~