| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1300090 | nub | Labels (NOI20_labels) | C++20 | 34 ms | 4704 KiB |
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define ci const int
#define cll const long long
#define cull const unsigned long long
#define cd const double
#define cld const long double
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define psf push_front
#define ppf pop_front
#define ps push
#define pp pop
using namespace std;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rand(ll l, ll r){
return uniform_int_distribution<ll>(l, r)(rng);
}
ci inf = 1e9;
ci neginf = -1e9;
cll inf_ll = 1e18;
cll neginf_ll = -1e18;
/*
It's ok to not get all the subtasks
Think of each subtask as a separate problem
The goal is to get as many points as possible
Solve if you can think of a method instantly (even brute force)
If not, skip and return later
Always check your code on multiple test cases
Consider offline processing when online is too messy
Consider processing in reverse
(If you're doing codeforces, maybe try to OneShot it)
Notes:
READ THE PROBLEM STATEMENT CAREFULLY
Check for double counting / undercounting
Clear arrays between testcases
Clear and resize arrays before algorithm
(Try to) Set default values for everything
Double check vector / array sizes
Remember to sort when (mostly) doing greedy
Check for max / min inputs
Check for edge cases
Check for 0-index vs 1-index bugs
Check loop bounds, PLEASE
"Losing a ton of points or time for no reason" counter: 14
*/
void solve(){
int n;
cin >> n;
vector<int> v(n);
v[0] = 0;
for (int i=1; i<n; i++){
int a;
cin >> a;
v[i] = v[i-1] + a;
}
int mi = inf, ma = neginf;
for (int i=0; i<n; i++){
mi = min(mi, v[i]);
ma = max(ma, v[i]);
}
if (ma-mi != n-1){
cout << "-1\n";
return;
}
for (int i=0; i<n; i++) cout << v[i]-mi+1 << " ";
}
string file_name = "";
string input_extension = "";
string output_extension = "";
int main(){
if (file_name.size() > 0 && input_extension.size() > 0){
freopen((file_name+input_extension).c_str(), "r", stdin);
}
if (file_name.size() > 0 && output_extension.size() > 0){
freopen((file_name+output_extension).c_str(), "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
auto start = chrono::high_resolution_clock::now();
int t=1;
// cin >> t;
while (t--) solve();
auto end = chrono::high_resolution_clock::now();
auto duration = chrono::duration_cast<chrono::microseconds>(end - start);
cerr << "\n\nRuntime: " << duration.count() / 1000.0 << " ms\n";
}
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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
