Submission #1296909

#TimeUsernameProblemLanguageResultExecution timeMemory
1296909nguyhoangphuWeighting stones (IZhO11_stones)C++20
0 / 100
1 ms332 KiB
#include<bits/stdc++.h> using namespace std; #define file "stone" #define int long long #define ll long long #define pii pair<int, int> #define pli pair<ll, int> #define fi first #define se second #define sz(a) (int)a.size() #define pb push_back #define mask(i) (1 << i) const int N = 1e5, inf = 1e9; void MAX(int &a, int b) { a = max(a, b); } void MIN(int &a, int b) { a = min(a, b); } struct stt { int i, w, tp; bool operator < (const stt &o) const { return i < o.i; } }; int n; int W[3], cnt[3]; vector<stt> a; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(file".in", "r")) { freopen(file".in", "r", stdin); freopen(file".out", "w", stdout); } cin >> n; for (int i = 1; i <= n; i++) { int p, tp; cin >> p >> tp; a.pb({p, i, tp}); } sort(a.begin(), a.end()); int val = 0, wmax = 0; for (stt x : a) { if (x.w > val) val = x.w, wmax = x.tp; W[x.tp] += x.w; cnt[x.tp]++; int kt = 0; if (W[1] > W[2] && cnt[1] >= cnt[2]) kt = 1; else if (W[2] > W[1] && cnt[2] >= cnt[1]) kt = 2; if (kt == wmax) { if (kt == 1) cout << ">\n"; else cout << "<\n"; } else cout << "?\n"; } }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen(file".in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     freopen(file".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...