Submission #960009

#TimeUsernameProblemLanguageResultExecution timeMemory
960009hariaakas646Lightning Conductor (POI11_pio)C++14
100 / 100
865 ms14164 KiB
#include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, j, k) for (int i = j; i < k; i++) #define frange(i, j) forr(i, 0, j) #define all(cont) cont.begin(), cont.end() #define mp make_pair #define pb push_back #define f first #define s second typedef long long int lli; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<lli> vll; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vi> vvi; typedef map<int, int> mpii; typedef set<int> seti; typedef multiset<int> mseti; typedef long double ld; void usaco() { freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin); // freopen("problem.out", "w", stdout); } int main() { // usaco(); int n; scd(n); vi vec(n); frange(i, n) scd(vec[i]); vi val; for(int i=0; i*i+1<=n; i++) { val.pb(i); } vi out(n); int ma = 0; frange(i, n) { for(auto e : val) { if(i - (e*e+1) < 0) break; ma = max(ma, vec[i-(e*e+1)] + e+1); } out[i] = ma; } ma = 0; for(int i=n-1; i>=0; i--) { for(auto e : val) { if(i + (e*e+1) >= n) break; ma = max(ma, vec[i+(e*e+1)] + e + 1); } out[i] = max(out[i], ma); } frange(i, n) { printf("%d\n", max(0, out[i]-vec[i])); } }

Compilation message (stderr)

pio.cpp: In function 'void usaco()':
pio.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pio.cpp: In function 'int main()':
pio.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
pio.cpp:37:5: note: in expansion of macro 'scd'
   37 |     scd(n);
      |     ^~~
pio.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
pio.cpp:40:18: note: in expansion of macro 'scd'
   40 |     frange(i, n) scd(vec[i]);
      |                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...