编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#2881 #1004. 提瓦特大冒险 Compile Error 0 0 ms 0 K C++ 17 / 952 B Mingzhen_Huang 2023-11-22 10:39:22
显示原始代码
#include <iostream>
using namespace std;

const int N = 1e5 + 10;
long long room_num, gift_num, time;  // 房间总数 奖励总数 时间
long long cost[N], gift_room[N], gift[N];

int main() {
    scanf("%lld %lld %lld", &room_num, &gift_num, &time);

    for (int i = 1; i <= room_num - 1; i++) {
        scanf("%lld", &cost[i]);
    }

    for (int i = 1; i <= gift_num; i++) {
        long long a, b;
        scanf("%lld %lld", &a, &b);
        gift_room[a]++;
        gift[a] = b;
    }

    int cur_room = 1;
    while (1) {
        if (gift_room[cur_room] == 1) {  //当前房间有奖励
            time += gift[cur_room];
        }
        if (time > 0) {
            time -= cost[cur_room];
            cur_room++;
        }
        if (time <= 0) {
            cout << "No";
            return 0;
        }
        if (cur_room == room_num) {
            cout << "Yes";
            return 0;
        }
    }
}

编译信息

/sandbox/1/a.cpp:5:31: error: 'long long int time' redeclared as different kind of entity
    5 | long long room_num, gift_num, time; // 房间总数 奖励总数 时间
      |                               ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/10/x32/bits/gthr.h:148,
                 from /usr/include/c++/10/ext/atomicity.h:35,
                 from /usr/include/c++/10/bits/ios_base.h:39,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from /sandbox/1/a.cpp:1:
/usr/include/time.h:75:15: note: previous declaration 'time_t time(time_t*)'
   75 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:9:25: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'time_t (*)(time_t*) noexcept' {aka 'long long int (*)(long long int*) noexcept'} [-Wformat=]
    9 |     scanf("%lld %lld %lld", &room_num, &gift_num, &time);
      |                      ~~~^                         ~~~~~
      |                         |                         |
      |                         long long int*            time_t (*)(time_t*) noexcept {aka long long int (*)(long long int*) noexcept}
/sandbox/1/a.cpp:25:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   25 |             time += gift[cur_room];
      |             ~~~~~^~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp:25:18: error: assignment of read-only location 'time'
/sandbox/1/a.cpp:28:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |             time -= cost[cur_room];
      |             ~~~~~^~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp:28:18: error: assignment of read-only location 'time'
/sandbox/1/a.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%lld %lld %lld", &room_num, &gift_num, &time);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%lld", &cost[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld %lld", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~