# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
769848 | anha3k25cvp | Segway (COI19_segway) | C++14 | 467 ms | 2024 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |