Submission #403122

# Submission time Handle Problem Language Result Execution time Memory
403122 2021-05-12T19:34:06 Z fidgetspinnerkid Traffic (IOI10_traffic) C++11
0 / 100
2 ms 460 KB
#include <bits/stdc++.h> // see /general/running-code-locally
using namespace std;

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

void setIO(string name = "") {
	cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
	if (sz(name)) {
		freopen((name+".in").c_str(), "r", stdin); // see /general/io
		freopen((name+".out").c_str(), "w", stdout);
	}
}

const int SZ = 1000;


int pref[SZ+1];

void fill_pref(int p[], int n) {
    for(int i=0; i<n; i++) {
        pref[i+1] = pref[i] + p[i];
    }
}

int LocateCentre(int n, int p[], int s[], int d[] ) {

    fill_pref(p, n);
    
    int sol = 0;
    int min_cong = 2000000001;
    for(int i=0; i<n; i++) {
        int s = max(pref[i], pref[n-1]-pref[i+1]);
        if(min_cong>s) {
            min_cong = s;
            sol = i;
        }
    }

}

Compilation message

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:39:9: warning: variable 'sol' set but not used [-Wunused-but-set-variable]
   39 |     int sol = 0;
      |         ^~~
traffic.cpp:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^
traffic.cpp: In function 'void setIO(std::string)':
traffic.cpp:19:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   freopen((name+".in").c_str(), "r", stdin); // see /general/io
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
traffic.cpp:20:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   freopen((name+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -