답안 #769848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
769848 2023-06-30T10:33:04 Z anha3k25cvp Segway (COI19_segway) C++14
100 / 100
467 ms 2024 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>

using namespace std;

const int N = 5 + 1e5;
const int inf = 7 + 1e9;

vector <int> vis, ans, cnt;
vector <vector <int>> a;

int main() {
#define TASKNAME ""
    ios_base :: sync_with_stdio (0);
    cin.tie (0);
    if ( fopen( TASKNAME".inp", "r" ) ) {
        freopen (TASKNAME".inp", "r", stdin);
        freopen (TASKNAME".out", "w", stdout);
    }
    int n;
    cin >> n;
    a.assign(n + 1, vector <int> (3, 0));
    for (int i = 1; i <= n; i ++)
        for (int j = 0; j < 3; j ++)
            cin >> a[i][j];
    int m;
    cin >> m;
    vis.assign(300, 0);
    while (m --) {
        int x;
        cin >> x;
        vis[x] = 1;
    }
    ans.assign(n + 1, 0);
    cnt.assign(n + 1, 0);
    for (int pos = 0; pos < 300; pos ++) {
        vector <int> c;
        for (int i = 1; i <= n; i ++)
            c.push_back(ans[i]);
        sort(c.begin(), c.end());
        for (int i = 1; i <= n; i ++) {
            if (vis[pos]) {
                int val = lower_bound(c.begin(), c.end(), ans[i]) - c.begin();
                if (!cnt[i])
                    cnt[i] = val % 20;
            }
            if (cnt[i]) {
                ans[i] ++;
                cnt[i] --;
            }
            else
                ans[i] += a[i][pos / 100];
        }
    }
    for (int i = 1; i <= n; i ++)
        cout << ans[i] << '\n';
    return 0;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:22:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen (TASKNAME".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:23:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen (TASKNAME".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 8 ms 340 KB Output is correct
4 Correct 35 ms 556 KB Output is correct
5 Correct 253 ms 1956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 3 ms 324 KB Output is correct
11 Correct 5 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 8 ms 340 KB Output is correct
4 Correct 35 ms 556 KB Output is correct
5 Correct 253 ms 1956 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 3 ms 212 KB Output is correct
15 Correct 3 ms 324 KB Output is correct
16 Correct 5 ms 320 KB Output is correct
17 Correct 10 ms 340 KB Output is correct
18 Correct 44 ms 468 KB Output is correct
19 Correct 156 ms 1044 KB Output is correct
20 Correct 150 ms 1236 KB Output is correct
21 Correct 296 ms 1512 KB Output is correct
22 Correct 467 ms 1944 KB Output is correct
23 Correct 439 ms 2024 KB Output is correct