Submission #332413

# Submission time Handle Problem Language Result Execution time Memory
332413 2020-12-02T10:41:15 Z beso123 Solar Storm (NOI20_solarstorm) C++14
0 / 100
2000 ms 218940 KB
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
const int N=(1e6)+3;
int n,s,r,d[N],v[N];
vector<int> g[N],prefl[N],prefr[N];
vector<int> b;
int pref[N];
main(){
cin>>n>>s>>r;
b.push_back(0);
for(int k=2;k<=n;k++){
    cin>>d[k];
    b.push_back(b[b.size()-1]+d[k]);
}
for(int k=1;k<=n;k++)
    cin>>v[k];
    g[1].push_back(1);
    int l=1;
for(int k=2;k<=n;k++){
    if(d[k]>r)
        l++;
    g[l].push_back(k);
}
for(int k=1;k<=l;k++){
        prefl[k].resize(g[k].size(),0);
    prefl[k][0]=v[g[k][0]];
    for(int i=1;i<g[k].size();i++)
        prefl[k][i]=prefl[k][i-1]+v[g[k][i]];
}
for(int k=1;k<=l;k++){
    int i=g[k].size()-1;
    int j=lower_bound(b.begin(),b.end(),b[g[k][i]-1]-r)-b.begin();
    j=g[k].size()-(g[k][i]-j);
    prefr[k].push_back(prefl[k][i]- ((j>0) ? prefl[k][j-1] : 0));
    while(i!=0){
        i=j-1;
        lower_bound(b.begin(),b.end(),b[g[k][i]-1]-r)-b.begin();
    j=g[k].size()-(g[k][g[k].size()]-j);
    prefr[k].push_back(prefl[k][g[k].size()-1]- ((j>0) ? prefl[k][j-1] : 0));
    }
}
for(int k=1;k<=l;k++){
    for(int i=0;i<prefr[k].size();i++)
        cout<<prefr[k][i]<<' ';
    cout<<endl;
}
return 0;
}

Compilation message

SolarStorm.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      |      ^
SolarStorm.cpp: In function 'int main()':
SolarStorm.cpp:19:1: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   19 | for(int k=1;k<=n;k++)
      | ^~~
SolarStorm.cpp:21:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   21 |     g[1].push_back(1);
      |     ^
SolarStorm.cpp:31:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=1;i<g[k].size();i++)
      |                 ~^~~~~~~~~~~~
SolarStorm.cpp:47:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i=0;i<prefr[k].size();i++)
      |                 ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 70892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 629 ms 218940 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 70892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2043 ms 176320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 70892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 70892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 70892 KB Output isn't correct
2 Halted 0 ms 0 KB -